Lavenderchan
Technical User
Hi I was wondering if anyone would have a clue why I keep getting this error message. i have a macro on the on click event that opens a form in edit mode. If I open it and try to run the code it give me the above error message. If I edit the macro it will work only while I have the database open.Once I close it out and go back in it doesn't work. I have read up on this error message and I cannot figrue out why I'm getting it. Any clarifation would be help ful.
I have convert from a macro to vba code so i could paste the code here:
Private Sub Control_Number_Click()
On Error GoTo Control_Number_Click_Err
On Error Resume Next
If (Form.Dirty) Then
DoCmd.RunCommand acCmdSaveRecord
End If
If (MacroError.Number <> 0) Then
Beep
MsgBox MacroError.Description, vbOKOnly, ""
Exit Sub
End If
On Error GoTo 0
DoCmd.OpenForm "Closed Correspondence Details", acNormal, "", "[ID]=" & Nz(ID, 0), acEdit, acDialog
If (Not IsNull(ID)) Then
TempVars.Add "CurrentID", "[ID]"
End If
If (IsNull(ID)) Then
TempVars.Add "CurrentID", "Nz(DMax(""[ID]"",[Form].[RecordSource]),0)"
End If
DoCmd.Requery ""
DoCmd.SearchForRecord , "", acFirst, "[ID]=" & TempVars!CurrentID
TempVars.Remove "CurrentID"
Control_Number_Click_Exit:
Exit Sub
Control_Number_Click_Err:
MsgBox Error$
Resume Control_Number_Click_Exit
End Sub
Thanks,
Keri
I have convert from a macro to vba code so i could paste the code here:
Private Sub Control_Number_Click()
On Error GoTo Control_Number_Click_Err
On Error Resume Next
If (Form.Dirty) Then
DoCmd.RunCommand acCmdSaveRecord
End If
If (MacroError.Number <> 0) Then
Beep
MsgBox MacroError.Description, vbOKOnly, ""
Exit Sub
End If
On Error GoTo 0
DoCmd.OpenForm "Closed Correspondence Details", acNormal, "", "[ID]=" & Nz(ID, 0), acEdit, acDialog
If (Not IsNull(ID)) Then
TempVars.Add "CurrentID", "[ID]"
End If
If (IsNull(ID)) Then
TempVars.Add "CurrentID", "Nz(DMax(""[ID]"",[Form].[RecordSource]),0)"
End If
DoCmd.Requery ""
DoCmd.SearchForRecord , "", acFirst, "[ID]=" & TempVars!CurrentID
TempVars.Remove "CurrentID"
Control_Number_Click_Exit:
Exit Sub
Control_Number_Click_Err:
MsgBox Error$
Resume Control_Number_Click_Exit
End Sub
Thanks,
Keri