"New Record" not possible after filter of form (1 Viewer)

markzaal

Registered User.
Local time
Today, 10:51
Joined
Jan 15, 2013
Messages
50
Access 2010

Hi all,

I use the following code to open a splitform filtered by projectnumber and create a new record:

DoCmd.OpenForm "ROVActivities3F", acNormal, "", "[ProjectNumber]=Forms!NewForms!LastProjectNumber", acFormEdit

DoCmd.RunCommand acCmdRecordsGoToNew

This all works fine when I have at least one record with this projectnumber. The first time I create a record with this projectnumber however (meaning the datasheet form is still empty) I get the error that the "acCmdRecordsGoToNew" command isn't available.
Any thoughts on how to fix this?

Thanks!

Mark
 

bob fitz

AWF VIP
Local time
Today, 09:51
Joined
May 23, 2011
Messages
4,726
Try this line of code:
DoCmd.GoToRecord , , acNewRec
in the On Open event of the form being opened instead of:
DoCmd.RunCommand acCmdRecordsGoToNew
 

markzaal

Registered User.
Local time
Today, 10:51
Joined
Jan 15, 2013
Messages
50
It was that simple! Thank you so much!
Just for future reference; what is the difference?
 

bob fitz

AWF VIP
Local time
Today, 09:51
Joined
May 23, 2011
Messages
4,726
Glad that worked for you.

I think the main difference is where the code is used.
 

Users who are viewing this thread

Top Bottom