talytech
09-25-2008, 09:26 AM
I want to write a program that will append data from the specified cells into the corresponding fields in my database table. I have the code that connects to the database and the code that runs the append query but what I don't know how to do is make the program loop and run the same code for each row that has data. For example .. I want the program to start at row 13 and run the code below. Then go to the next row and run the code. ... and continue until the next row has no data.
qdfAddRequest = "INSERT INTO tblKeyRequests ([SOL#], RequestorName, UserId, DateRequested, keysRequested, created, modifiedby ) " _
& "SELECT '" & solnum & "' AS solnum, '" & fullnm & "' AS rqstor, '" & usrId & "' AS usrId, '" & reqstd & "' AS datereqsted, '" & totkeys & "' AS totkeys, '" & created & "' AS created, '" & ModifiedBy & "' AS createdby;"
dbsKeys.Execute qdfAddRequest
Note: the variables have already been defined.
qdfAddRequest = "INSERT INTO tblKeyRequests ([SOL#], RequestorName, UserId, DateRequested, keysRequested, created, modifiedby ) " _
& "SELECT '" & solnum & "' AS solnum, '" & fullnm & "' AS rqstor, '" & usrId & "' AS usrId, '" & reqstd & "' AS datereqsted, '" & totkeys & "' AS totkeys, '" & created & "' AS created, '" & ModifiedBy & "' AS createdby;"
dbsKeys.Execute qdfAddRequest
Note: the variables have already been defined.