Cycle through query records and append to a table

dmenger

New member
Local time
Yesterday, 17:43
Joined
Jul 23, 2013
Messages
6
Hi All,
New to Access could have done this in excel in a heartbeat. :banghead:

Looking to perform a query then cycle through each record and spit out each serial number into another table in a single record. Please Help

Code:
Sub SN()
Dim Form As Form_NCR
Dim QueryLR, NCRLR, NextSN As Integer
Set NextSN = 1
'Find Last record of query "NCR Search"
Set QueryLR = ?
'Find Last record of Table "NCR"
Set NCRLR = ?
' Loop through Each record in query
For i = 1 To QueryLR
' Loop through each serial number in that record
For j = 1 To 20
' If Feild is not blank then copy feild to last row of "NCR" Table in the next avaliable serial number feild.
If Query![NCR Search][Serial Number & j] <> "" Then
Query![NCR Search][Serial Number & j]= Table![NCR][Serial Number & NextSN]
NextSN = NextSN + 1
End if
Next j
Next i

End Sub
 

Users who are viewing this thread

Back
Top Bottom