B
Bob Richardson
Here's coding of an OnClick event for an "Add Event" button. The idea was to
add the record, then open a form which will allow entering of all other
fields. The OpenForm event has some sort of syntax error. After entering a
new code, e.g. ag01, I get a dialog box with the above error message. If I
reenter the code, it looks like everything works correctly; however, it's
silly to have to enter the code twice. What have I done wrong. The primary
key to the Events file is EvCode.
Code = InputBox$("Enter New Event Code...usually formatted AAnn", "XX99")
If Code = "" Then
Exit Sub
End If
Code = UCase$(Code)
rs.AddNew
rs.Fields("EvCode") = Cstr(Code)
rs.Fields("EventName") = "This must be entered"
rs.Update
DoCmd.OpenForm "EventForm", , , "[Events.EvCode]=" & Code
add the record, then open a form which will allow entering of all other
fields. The OpenForm event has some sort of syntax error. After entering a
new code, e.g. ag01, I get a dialog box with the above error message. If I
reenter the code, it looks like everything works correctly; however, it's
silly to have to enter the code twice. What have I done wrong. The primary
key to the Events file is EvCode.
Code = InputBox$("Enter New Event Code...usually formatted AAnn", "XX99")
If Code = "" Then
Exit Sub
End If
Code = UCase$(Code)
rs.AddNew
rs.Fields("EvCode") = Cstr(Code)
rs.Fields("EventName") = "This must be entered"
rs.Update
DoCmd.OpenForm "EventForm", , , "[Events.EvCode]=" & Code