G
Guest
I'm trying to load a table with records based on a previously executed
dlookup() statement.
I obviously don't know the first thing about do ... loops in VB or Access
(in ABAP I could do a select.. endselect statement to loop through a table
and do all sorts of things in between).
Can someone please set me straight on this or give me a link that shows
examples?
Here is what I want to do in English...
‘I have a RetUserID from a dlookup() statement further up in the code;
strSQL = "INSERT INTO tblSuperTemp (superid) values ('" & [RetUserID] & "')"
DoCmd.RunSQL strSQL 'this updates the table
strSQL = "" 'this clears the string
'load tblTempHold with employees under supervisor
Do while there are records to read
‘initialize values
SupersEmpID = ""
SupersEmpLName = ""
SupersEmpFName = ""
SupersEmpID = Nz(DLookup("EmployeeID", "TblEmp", "SupervisorID ='" &
[RetUserID] & "'"))
SupersEmpLName = Nz(DLookup("Lname", "TblEmp", "SupervisorID ='" &
[RetUserID] & "'"))
SupersEmpFName = Nz(DLookup("Fname", "TblEmp", "SupervisorID ='" &
[RetUserID] & "'"))
strSQL = "INSERT INTO ..... " etc.
DoCmd.RunSQL strSQL
'keep looping until there are no more records in TblEmp
Loop
I'll turn off the warnings before the do...loop and turn them back on. Am I
even on the right track here?
Help!
tia,
dlookup() statement.
I obviously don't know the first thing about do ... loops in VB or Access
(in ABAP I could do a select.. endselect statement to loop through a table
and do all sorts of things in between).
Can someone please set me straight on this or give me a link that shows
examples?
Here is what I want to do in English...
‘I have a RetUserID from a dlookup() statement further up in the code;
strSQL = "INSERT INTO tblSuperTemp (superid) values ('" & [RetUserID] & "')"
DoCmd.RunSQL strSQL 'this updates the table
strSQL = "" 'this clears the string
'load tblTempHold with employees under supervisor
Do while there are records to read
‘initialize values
SupersEmpID = ""
SupersEmpLName = ""
SupersEmpFName = ""
SupersEmpID = Nz(DLookup("EmployeeID", "TblEmp", "SupervisorID ='" &
[RetUserID] & "'"))
SupersEmpLName = Nz(DLookup("Lname", "TblEmp", "SupervisorID ='" &
[RetUserID] & "'"))
SupersEmpFName = Nz(DLookup("Fname", "TblEmp", "SupervisorID ='" &
[RetUserID] & "'"))
strSQL = "INSERT INTO ..... " etc.
DoCmd.RunSQL strSQL
'keep looping until there are no more records in TblEmp
Loop
I'll turn off the warnings before the do...loop and turn them back on. Am I
even on the right track here?
Help!
tia,