I've been playing with this a bit but still no luck. I wrote some basic test code with messages to tell me what record I'm on. First I assigned the code to a test command button's OnClick. It worked fine. I then assigned the code to the form's OnClose and it always grabbed the data for record #1 (Request_No). Next, I tried the BeforeUpdate and AfterUpdate but still no luck.
Here's my code...
OnClose CODE:
If Me.Grades = -1 Then
If Me.Request_No > 0 Then
GoTo GoodBye
Else
DoCmd.RepaintObject
DoCmd.RunCommand acCmdSaveRecord
DoCmd.RunSQL "INSERT INTO tblGrades ( Permit_No, RequestDate, Location, Contractor, RequestBy, Phone, RequestTime )SELECT tblPermits.Permit_No, tblPermits.PermitDate, tblPermits.Par_Addr, tblPermits.Contractor, tblPermits.RequestBy, tblPermits.Phone, txtTime FROM (tblPermits INNER JOIN tblLegals ON tblPermits.Notice_ID = tblLegals.Notice_ID) LEFT JOIN tblContractor ON tblPermits.Contractor = tblContractor.Contractor WHERE ((([tblPermits.Permit_No])=[forms]![frmPermits]![Permit_No]))"
DoCmd.OpenForm "frmGrades"
DoCmd.RunCommand acCmdRecordsGoToLast
End If
Else
End If
GoodBye:
Command Button OnClick TEST CODE:
If Me.Grades = -1 Then
If Me.Request_No > 0 Then
MsgBox "NOPE" & " - " & Me.Request_No
GoTo GoodBye
Else
MsgBox "YUP" & " - " & Me.Request_No
End If
Else
MsgBox "NOPE" & " - " & Me.Request_No
End If
GoodBye:
I'm probably missing some little thing, but I'm no programmer so please bear with me.
Thanks again,
SKK