Open Form to Blank Record (1 Viewer)

depawl52

New member
Local time
Today, 18:27
Joined
Feb 8, 2022
Messages
14
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.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 06:27
Joined
May 7, 2009
Messages
16,867
is your query updateable?
 

mike60smart

Registered User.
Local time
Today, 23:27
Joined
Aug 6, 2017
Messages
1,237
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
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 18:27
Joined
Feb 19, 2002
Messages
36,943
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
 

CJ_London

Super Moderator
Staff member
Local time
Today, 23:27
Joined
Feb 19, 2013
Messages
14,736
form open event is too soon - the data has not been loaded, use the form load event
 

depawl52

New member
Local time
Today, 18:27
Joined
Feb 8, 2022
Messages
14
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.
 

depawl52

New member
Local time
Today, 18:27
Joined
Feb 8, 2022
Messages
14
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
?
 

mike60smart

Registered User.
Local time
Today, 23:27
Joined
Aug 6, 2017
Messages
1,237
You need to amend the query to make it updateable.
 

depawl52

New member
Local time
Today, 18:27
Joined
Feb 8, 2022
Messages
14
Since my Query calculates a sum, average, count, etc. on the values in a field, I presume that it is not updateable. correct?
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 18:27
Joined
Feb 19, 2002
Messages
36,943
Correct. The query will not be updateable.
 

Users who are viewing this thread

Top Bottom