Thanks for getting back to me about this.
The table name is Time, and the MAX(EntryID) should really be part of the Where part of the command (I think). What it is trying to do is find a record in the Time table with the highest entry ID (MAX(EntryID)) where the first name matches that on the form, and the signature out data is blank, then update that field with the needed details.
I'll take a look at the format and see if changing it helps.
Bort
Edit:
I've now changed the SQL command to read "UPDATE Time SET TimeOut = " & TimeString & " , SignatureOutData = " & SigString & " WHERE MAX(EntryID) and FirstName = " & cmbName.Text & " and TimeOut = NULL" but it still does not work. I also tried changing the 'and's in the WHERE part of the command to ',' too, but this did no good. Trying to list it like you showed in your example didn't do anything either, just caused more errors because it only took the first line as the command and ignored the rest. I could have used _ to make it look at the next few lines, but it was just as easy to have the entire command on one line.
Been trying to set up the UPDATE statement again, this time with different formatting.
CODE
Dim myConnection As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source='" & Application.StartupPath & "\Reg v2.mdb'")
Dim SQLCmd As New OleDbCommand
Dim SQLStr As String = "UPDATE [Time] SET TimeOut = '" & TimeString & "' , SignatureOutData = '" & SigString & "' WHERE Date = '" & DateTime.Today & "' and FirstName = '" & cmbName.Text & "' and TimeOut = ''"
myConnection.Open()
SQLCmd.Connection = myConnection
SQLCmd.CommandText = SQLStr
SQLCmd.ExecuteNonQuery()
myConnection.Close()
This is what comes of spending all day working on a really annoying problem...
This post has been edited by Bort: 16 Jun, 2008 - 06:47 AM