Open Form to Blank Record

depawl52

New member
Local time
Today, 03:47
Joined
Feb 8, 2022
Messages
22
Greetings all. I have a simple form with one unbound (combobox) and 4 bound (test boxes) controls.
The form has a query as it's control source.
I need to have the form open to a blank record, but it opens to the first record.
I've tried:
Call DoCmd.GoToRecord(, , acNewRec)
in the Open Form event, and get an error:
"You can't go the specified record"
I've tried to set the controls to "" On Open,
but I get an:
"This recordset is not updatable" error.
So I'm wondering as to how this might be accomplished.
Thanks.
 
is your query updateable?
 
Greetings all. I have a simple form with one unbound (combobox) and 4 bound (test boxes) controls.
The form has a query as it's control source.
I need to have the form open to a blank record, but it opens to the first record.
I've tried:
Call DoCmd.GoToRecord(, , acNewRec)
in the Open Form event, and get an error:
"You can't go the specified record"
I've tried to set the controls to "" On Open,
but I get an:
"This recordset is not updatable" error.
So I'm wondering as to how this might be accomplished.
Thanks.
If you open the query in datasheet view and try adding extra characters into any field, do you get the message "query is not updateable"?

Also the DoCmd.GoToRecord should be this:-

DoCmd.GoToRecord , , acNewRec
 
Assuming you have an unbound combo on the form that you will use to select the record you want, then add criteria to the form's RecordSource query:

Where SomeField = Forms!myform!cboSomeField;

Since the combo will be empty when the form opens, it will be at the "new" record.

In the AfterUpdate event of the search combo, requery the form:

Me.Requery
 
form open event is too soon - the data has not been loaded, use the form load event
 
If you open the query in datasheet view and try adding extra characters into any field, do you get the message "query is not updateable"?

Also the DoCmd.GoToRecord should be this:-

DoCmd.GoToRecord , , acNewRec
Yes, in the query in datasheet view, I do get the message "Query is not updateable". Also entering DoCmd.GoToRecord , , acNewRec in the forms On Load Event gives a Runtime error '2105': You can't go to the specified record.
 
Assuming you have an unbound combo on the form that you will use to select the record you want, then add criteria to the form's RecordSource query:

Where SomeField = Forms!myform!cboSomeField;

Since the combo will be empty when the form opens, it will be at the "new" record.

In the AfterUpdate event of the search combo, requery the form:

Me.Requery
Thank you Pat. So assuming some field is CustID, and myform is named OrdersF, and the cbo is NameC, would the correct syntax be:
CustID = Forms!OrdersF!NameC!CustID
?
 
You need to amend the query to make it updateable.
 
Since my Query calculates a sum, average, count, etc. on the values in a field, I presume that it is not updateable. correct?
 

Users who are viewing this thread

Back
Top Bottom