Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form to display new record first

Status
Not open for further replies.

pitrevie

Technical User
Apr 28, 2002
2
0
0
TH
How do you get a form to display the new record when you open it rather than the first record?
 
On the forms 'OnOpen' event use this:

DoCmd.GoToRecord , , acNewRec

HTH

Nigel
 
Hi mrf1xa ,

I m also having the same problem with pitrevie. . . i tried to implement ur method but it dun work.


This is what i did, i open my form in design view then right click to properties & click on Tabs that show event.

Then i see an 'OnOpen' event which cut & paste this command in it " DoCmd.GoToRecord , , acNewRec "

After i save the form & exec it again an erro msg shows up & says that DoCmd cannot be found in macro?


I will be most glad if anyone ans my qns A.S.A.P

 
Zinkey

You are nearly there! When you are viewing the events tab of the property sheet, you can't just paste my code directly in as Access then thinks it is the name of a macro, hence the error. Here's what to do:

Delete the code you have pasted into the OnOpen line, then click the build button to the right of the line- the one with 3 little dots in it. Select Code Builder and you will end up with the code screen, with an event already created- starts Private Sub and ends End Sub. You need to paste my code in between these two lines so it looks like this:

Private Sub Form_Open(Cancel As Integer)
DoCmd.GoToRecord , , acNewRec
End Sub

now save and close the code window and give it a try...

hth

Nigel
 
Another way would be to modify the 'Data Entry' property of the form and change it to 'Yes'. In the case of mrf1xa's recommendation when you open the form it will immediately go to a new record. After that you may then use the regular navigation buttons the go previous or add new or whatever. With this alternative the user will be in data entry mode continuously. Each obviously has it's advantages so you need to match it to your requirements.

Steve King Growth follows a healthy professional curiosity
 
Thnx alot guys for your help...(Nigel & Steve)

I think i will use Steve's method since it suit my prog format better :p

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top