VBA code to open MS Access form to new, blank record
My code is as suggested in the five-year-old posting, but it doesn't work:
Thank you for taking the time to report an issue.
What's wrong... Please write below.
I do not want this to happen. I had written a vba code to set the form to read-only thinking that would help, but it hasn't.
Here's the code I used to make the form read-only and for it to open to a blank form:
I have a couple other forms as well, such as an add record form, an update record form, and a delete record. I made separate forms, so we could better control our documents as all are restricted with passwords, except the search record form.
Another from a form that filters to meet a specific Employee Number. When I open the form from the switchboard (all records) the last row is a blank record. When I open with the filter on, the blank record does not exist. I have "Allow Additions" set to true, so what is causing this behavior?
Private Sub btnAddNewRecord_Click()
DoCmd.GoToRecord , , acNewRec 'goes to open record
Me.cboDriverNumber.SetFocus 'sets focus to combo box
It works fine when I open from the switchboard (with all records displayed from the query). It does not work and there is no blank record when I open it from the form with the filter applied.
I did this because when I would search for a record by a particular field, by Document Number for example, the data I typed into the text box, or selected in the combo box, would then bestored as a new record in my table, which I did not want.
So, by doing this my Search button no longer works.
Now, do I need to write a VBA code consisting of information that will let me search by each field? For instance, in my code do I need to include information that will let me search by theDocument Number, and/or File Type, and/or Revision, and/or Project, and/or Manufacturer, and so forth?
I have been searching all day for example VBA codes for searching, but have not been successful.
"Microsoft Office Access can't find the form 'ContactForm' referred to in a macro expression or Visual Basic code."
'ContactForm' is the name of the form I'm trying to get/set the properties on.
Here's the code I'm running:
However, when I open this second form up by itself these buttons function as they should.
@AccessMSSQL mentioned that when I open the second form through the command button, this may cause only one record to be displayed so I can't move to next or previous.
The purpose of this is due to a multi-user environment application that I want the user to see his/her profile when open the form.
The user enters the info in a VBA Form and I want to transfer this data to Access.
How can I do this?
The table opens but only the first record is updated. The code works well as a standard VBA search code on another form.