Tupacmoche
Registered User.
- Local time
- Today, 14:53
- Joined
- Apr 28, 2008
- Messages
- 291
I have a form that collects three (3) user selected values that are inserted into a table. I want to run the script below so that it uses the values entered into the table to 'drive' the update process of another table. Here is the code:
Dim K_id As String
Dim HowMany As Integer
Dim Code As String
K_id = myOthTbl.Caller
HM = myOthTbl.HowMany
Code = myOthTbl.Code
strSQL = "Update mytbl as y Set y.Call_Assign_to =" K_id & _
"Where Id_Num in (Select Top" &" HM " & " t.Id_Num" & _
"From Tkn as t " & _
"inner join mytbl as y on y.Id_Num = t.Id_Num " & _
"where y.Call_Assign_to IS NULL" & _
"and x.poky = Code" & _
"order by xyz DESC"
DoCmd.RunSQL strSQL
The variable K_id become a users id, the HM would become an int number for the select Top part of the script and finally the Code variable would become the code selected.
As you can see there are three (3) variables that hold table values and are used in the script. Ideally, I would like to loop through the table that may have twenty (20) or more rows to update all the records in a different table.:banghead:
Dim K_id As String
Dim HowMany As Integer
Dim Code As String
K_id = myOthTbl.Caller
HM = myOthTbl.HowMany
Code = myOthTbl.Code
strSQL = "Update mytbl as y Set y.Call_Assign_to =" K_id & _
"Where Id_Num in (Select Top" &" HM " & " t.Id_Num" & _
"From Tkn as t " & _
"inner join mytbl as y on y.Id_Num = t.Id_Num " & _
"where y.Call_Assign_to IS NULL" & _
"and x.poky = Code" & _
"order by xyz DESC"
DoCmd.RunSQL strSQL
The variable K_id become a users id, the HM would become an int number for the select Top part of the script and finally the Code variable would become the code selected.
As you can see there are three (3) variables that hold table values and are used in the script. Ideally, I would like to loop through the table that may have twenty (20) or more rows to update all the records in a different table.:banghead: