Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Statement Current Row

Status
Not open for further replies.
Nov 7, 2002
61
US
I'm trying to write a SQL statement that when a certain criteria is met in the VBA script that it will write the current row of data to an already existing table in Access. The below statement works, but it only writes the top row of data. I need to determine what the current record is, and write the four fields of data to the table.

Public Sub WriteError()
Dim SQLStr As String
strSQL = "INSERT INTO [tblErrorLog2] (ErrName, ErrDT, ErrDesc, ErrValue) " & _
"VALUES ('" & CSRNAME & "', '" & CSRDT & "', '" & CSRDESC & "', '" & CSRVAL & "');"

DoCmd.SetWarnings False
DoCmd.RunSQL (strSQL)
DoCmd.SetWarnings True
End Sub

I tried "WHERE RowID = '"& Me!RowID & "'";", but that didn't work.

Thanks for your help. These forums have helped me a lot, even when just reading old threads.

Mike
 
I created a variable iCount which I incremented with iCount = iCount + 1 each time the loop ran through. I then added "WHERE ErrorID=" & iCount & ";" to my SQL statement and it ran perfectly.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top