I hope someone can help, I have a data entry form with save button, and I want to set it up so that the user doesn't have to worry about if they've already saved the details or not. They just press save and it'll insert a new record, or if they make amendments to what's been entered on the form then it'll simply update the record instead.
However my update statement doesn't seem to want to work. I have an IF statment with the sql update in the else statement. I know that this is being triggered as the message box appears, but the sql statement isn't executing. I've tested the query in SQL and it works fine, but it doesn't seem to want to execute in VBA.
The code is:
However my update statement doesn't seem to want to work. I have an IF statment with the sql update in the else statement. I know that this is being triggered as the message box appears, but the sql statement isn't executing. I've tested the query in SQL and it works fine, but it doesn't seem to want to execute in VBA.
The code is:
Code:
If DCount("EstateInspection", "qryCheckEstateInspection") = 0 Then
Call saveReading
MsgBox "Inspection details saved. "
Else
' DoCmd.SetWarnings True
strSQL2 = "Update tblEstateInspections " & _
"Set [LobbyStairs] = '" & [Forms]!frmInspection.cboOne & "' , [WallsCeilings] = '" & [Forms]!frmInspection.cboTwo & "' " & _
", CommunalLighting = '" & [Forms]!frmInspection.cboFour & "' , Grounds = '" & [Forms]!frmInspection.cboFive & "' " & _
", ChuteRoom = '" & [Forms]!frmInspection.cboSix & "' , CommunalWindows = '" & [Forms]!frmInspection.cboThree & "' " & _
", EntryPhone = '" & [Forms]!frmInspection.cboSeven & "' , GroundsMaintenence = '" & [Forms]!frmInspection.chkGrounds & "' " & _
", ASBInBlock = '" & [Forms]!frmInspection.chkSocial & "' , AbandondVehicles = '" & [Forms]!frmInspection.chkStreetClean & "' " & _
"Where [StairID] = " & [Forms]!frmInspection.cboStairs & " " & _
"and Inspectiondate = " & [Forms]!frmInspection.txtDate
DoCmd.RunSQL strSQL2
Debug.Print strSQL2
MsgBox "Updated."
End If