I've read a lot about others having this problem, but none of what I've read is helping me with my problem. I have a main menu form which opens at startup. On that form is a button which is supposed to open another form for a new record. The code behind the Click event for this button is as follows:
There is also a listbox showing pre-existing data on the main menu. If I click the AddButton without first choosing a record in the listbox, I get an error (2051), however, if I first choose a value in the listbox, everything works as it should. Is there a simple way for me to get the AddButton to work whether or not I choose a listbox value?
FYI, the form DataForm is not used exclusively for new records but also to view and edit existing records.
Thanks in advance!
Code:
On Error GoTo Err_AddButton_Click
Dim stDocName As String
stDocName = "DataForm"
DoCmd.OpenForm stDocName, , , , _
acFormAdd
DoCmd.GoToRecord , , acNewRec
Exit_AddButton_Click:
Exit Sub
Err_AddButton_Click:
MsgBox Err.Description
Resume Exit_AddButton_Click
There is also a listbox showing pre-existing data on the main menu. If I click the AddButton without first choosing a record in the listbox, I get an error (2051), however, if I first choose a value in the listbox, everything works as it should. Is there a simple way for me to get the AddButton to work whether or not I choose a listbox value?
FYI, the form DataForm is not used exclusively for new records but also to view and edit existing records.
Thanks in advance!