Hello, i am wanting a Loop procedure to check details of all the multiple rows with the following D-LOOKUP procedures; - [*]StkID.Value = DLookup("[StkID]", "stkmas", "[StkShortDesc] = Forms![frmPreSOLine]![StkShortDesc]")[*]Price.Value = DLookup("[SalePrice1]", "primas", "[StkID] = Forms![frmPreSOLine]![StkID]")
For the Loop procedure to work i have used the following code: - Dim dbs As Database
-
Dim rst As Recordset
-
Dim Reply As String
-
Dim strSQL As String
-
-
Set dbs = CurrentDb
-
Set rst = dbs.OpenRecordset("SELECT * FROM preordlin")
-
strSQL = "INSERT INTO stkmas ([StkShortDesc],[Width],[Depth],[Height]) SELECT [StkShortDesc],[Width],[Depth],[Height] FROM preordlin WHERE IsNull(StkID)"
-
-
Do Until rst.EOF
-
StkID.Value = DLookup("[StkID]", "stkmas", "[StkShortDesc] = Forms![frmPreSOLine]![StkShortDesc]")
-
Price.Value = DLookup("[SalePrice1]", "primas", "[StkID] = Forms![frmPreSOLine]![StkID]")
-
rst.MoveNext
-
Loop
-
-
If IsNull(StkID) Then
-
Reply = MsgBox("There are Stock Items that present that do not belong to our existing Stock files. Would you like to ADD then?", vbYesNo, "None Existent Stock Details!")
-
If Reply = vbYes Then
-
DoCmd.RunSQL strSQL
-
Else
-
End If
-
Else
-
End If
The only problem is when i click on the button to execute this procedure, it works but only works on 1 row at a time and you have to keep clicking the button on all the rows of data. Is there a way that does it for all of them at once?
Please help!
Thanks in advance.
Chris
2 3162 ADezii 8,834
Recognized Expert Expert
Just subscribing, I took the liberty of rewriting your code for the sake of clarity. I realize that you are new to this, but in the future, kindly use the Code Tags for obvious reasons. I really don't have the time now to help you with a Reply to this Thread, but I'll check back later and in the meantime, I'm sure someone will provide you with assistance. - StkID.Value = DLookup("[StkID]", "stkmas", "[StkShortDesc] = Forms![frmPreSOLine]![StkShortDesc]")
- Price.Value = DLookup("[SalePrice1]", "primas", "[StkID] = Forms![frmPreSOLine]![StkID]")
'For the Loop procedure to work i have used the following code: - Dim dbs As DAO.Database
-
Dim rst As DAO.Recordset
-
Dim Reply As String
-
Dim strSQL As String
-
-
Reply = "There are Stock Items that present that do not belong to our " & _
-
"existing Stock files. Would you like to ADD then?"
-
-
Set dbs = CurrentDb
-
Set rst = dbs.OpenRecordset("SELECT * FROM preordlin")
-
strSQL = "INSERT INTO stkmas ([StkShortDesc],[Width],[Depth],[Height]) SELECT " & _
-
"[StkShortDesc],[Width],[Depth],[Height] FROM preordlin WHERE IsNull(StkID)"
-
-
Do Until rst.EOF
-
StkID.Value = DLookup("[StkID]", "stkmas", "[StkShortDesc] = Forms![frmPreSOLine]![StkShortDesc]")
-
Price.Value = DLookup("[SalePrice1]", "primas", "[StkID] = Forms![frmPreSOLine]![StkID]")
-
rst.MoveNext
-
Loop
-
-
If IsNull(StkID) Then
-
Reply = MsgBox(Reply, vbYesNo, "None Existent Stock Details!")
-
If Reply = vbYes Then
-
DoCmd.RunSQL strSQL
-
Else
-
End If
-
Else
-
End If
NeoPa 32,577
Recognized Expert Moderator MVP
It's not clear what you're trying to achieve, but if you look at lines #10 through #14 (Do Until ... Loop) you will see that they assign values to a couple of items which are neither explained nor referred to elsewhere.
As the first thing you do after assigning them once is to assign them again with (presumably) different values, it's clear to see that this loop is not doing anything for you. If these objects are form controls then there will be no time to see them before they disappear again. Only the last record will remain visible. If they are intended to reference fields in a recordset somewhere (they don't) then apart from that they are never written away anyway (No rst.Edit & rst.Update are ever called).
Hopefully these pointers will help you find your problems. I'm afraid your question is otherwise too unclear to help further.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Eric |
last post by:
Let me start off by saying I have VB working model which means no help. I
have searched MSDN. It seems that I get "Read the help" instead of answers
which is totally useless to me. With that said can someone please help me
understand why this does not work?
Dim x As String
Private Sub cmdlogin_Click()
Do Until x = "Corey"
If txtlogin = "Corey" Then
|
by: .Net Sports |
last post by:
I am trying to display records from a recordset after sql statement:
<% sqlstr ="SELECT horsename FROM tblhorseentry WHERE trackname = '" &
request.querystring("trackname") & "' and racedate = '" &
request.querystring("racedate");"
Set rs1 = Server.CreateObject("ADODB.Recordset")
rs1.Open sqlstr,pConn,3
|
by: MLH |
last post by:
Take a look at the code that follows. Line 110 is the beginning
of Do-Loop. Regarding line #220, I find that I'm getting Error #3021
(No Current Record) during execution of line #230. It puzzles me
as to Why? I thought if I was on last valid record of RecSet when
line #220 executes, I would be sent to process lines after line #400.
Am I wrong about that?
==> BEGIN CODE SNIPPET <===
110 Do Until RecSet.EOF
StartAnew:
|
by: jcrouse |
last post by:
I am having problems with a Label_Paint event causing a continuous loop.
Here is an explanation of the code.
I right click on a label and a context menu pops up.
I then select a menu item named "cmLSolidColor". Here is its code:
|
by: shannon |
last post by:
Hello,
I am wondering if a Do until loop can be used in Javascript. I have an
array and want to fill the array 10 times with the users details until
it reaches 10 or if they press cancel. I'm using window.prompt to get
user info. Any suggestions.
Do {
//ask user to input their details
} while (myairline !=10);
| |
by: abitlikehomer |
last post by:
Hi i am writing a bit of code so that the date and time of a booking can not be booked twice but i am getting an error message saying "loop without do". Any suggestions?
setflag = False
Do Until EOF(1) Or setflag = True
If customer.bookingdate <> txtdate Then
GoTo loopend
If txttimefrom >= customer.timefrom And txttimefrom < customer.timeto Then
setflag = True
Else
' 'potentially ok'
|
by: Madhavi |
last post by:
Hi
Is there any Do Until Loop in C#
Maadhavi
|
by: SyGC |
last post by:
Hi People,
Im trying to do a simple Loop where by an IP address is pinged (Using My.computer.network.ping) and the results, true or false, are used to invoke another line of code.
Basically if the IP is pingable (true) image A is displayed if it is not (false) then image B is.
The code i am using is as follows
Dim IPAddress As String = "192.168.1.122"
|
by: dbrother |
last post by:
Access 2003 Win XP Pro SP3
Using SQL /ADO Recordsets in a Do Loop
Hello,
I'm using a random number generator based on an integer input from a user from a form that will get X number of random records from an external Oracle source using a SQL statement. The SQL statement works as expected when the loop code is commented out, but I receive an error "SQL command not properly ended" when the loop is active.
Do Until intLoop = UserNum
...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |