Help with opening a form to new record

browninaz

Ugly Data Hoarder
Local time
Yesterday, 23:06
Joined
Oct 26, 2012
Messages
88
Hello all,

I have a form that I want to open to a new record. I set the data entry to yes under the data tab on the property sheet and saved the form, but the form still opens to the first record. So, I created a new macro to open the form to a new record, and that is not working. :banghead: I compacted and repaired my data base , did it all again, and still no go. It worked last night when I performed these actions, and now its not.

Some one please help!

Thanks in advance to all the programmers out there.
 
Try the following in the Form's On Load event;
Code:
DoCmd.[URL="http://msdn.microsoft.com/en-us/library/office/bb237964%28v=office.12%29.aspx"]GotoRecord[/URL] acDataForm, "YourFormName, acNewRec
 
Thanks John, but I still suck at the code game until next semester is over. I copied and pasted the code above, changed "YourFormName to the actual name of my form, and I get the error message "If 'DoCmd' is a new macro or macro group, make sure you have saved it and that you have typed its name correctly"

I have no idea what I'm doing. I have been winging this database file for a year now, broke it down several times after creating very elaborate forms and reports, and now I can almost taste victory in the completion of this monster. The only code I am familiar with is HTML and CSS, and have never dealt with VBA or SQL. So, to make a long story short, I really have no idea what I'm doing...
 
Did you select Event Procedure form the drop down list and then click the ellipsis button to the right (that's the little button with the three full stops on it)

attachment.php


This will then open the code window into which you can paste the code;

attachment.php
 

Attachments

  • Capture.PNG
    Capture.PNG
    42.5 KB · Views: 774
  • Capture2.PNG
    Capture2.PNG
    10 KB · Views: 759
OK John, I did that. Do I click "run"?
 
Close the form and then Open it the event should fire and the form should open at a new record.
 
Hey John, I got the "Run-time error '2489':

The object 'frmNewCustomerContract, acNewRec' isn't open.
 
My bad :( I missed the closing double quote in my code above, it should read;
Code:
DoCmd.GotoRecord acDataForm, "YourFormName[B][COLOR="Red"]"[/COLOR][/B], acNewRec
 

Users who are viewing this thread

Back
Top Bottom