Open Form to Blank Record (1 Viewer)

depawl52

New member
Local time
Today, 04:29
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.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 16:29
Joined
May 7, 2009
Messages
19,094
is your query updateable?
 

mike60smart

Registered User.
Local time
Today, 08:29
Joined
Aug 6, 2017
Messages
1,896
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, 04:29
Joined
Feb 19, 2002
Messages
42,872
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, 08:29
Joined
Feb 19, 2013
Messages
16,521
form open event is too soon - the data has not been loaded, use the form load event
 

depawl52

New member
Local time
Today, 04:29
Joined
Feb 8, 2022
Messages
22
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, 04:29
Joined
Feb 8, 2022
Messages
22
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, 08:29
Joined
Aug 6, 2017
Messages
1,896
You need to amend the query to make it updateable.
 

depawl52

New member
Local time
Today, 04:29
Joined
Feb 8, 2022
Messages
22
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, 04:29
Joined
Feb 19, 2002
Messages
42,872
Correct. The query will not be updateable.
 

Users who are viewing this thread

Top Bottom