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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Desperate for new record clause

Status
Not open for further replies.

KellyJo

Technical User
Sep 14, 2004
24
US
Hi! I am looking for some code that will help me with a staffing form I am doing.

After entering in the name and date scheduled fields, I'd like to be able to go to a new record that will automatically have the name field populated with the same value as the previous record. I am stuck on the populating the field part. Here's what I have:

Private Sub Date_Scheduled_AfterUpdate()
DoCmd.GoToRecord , , acNewRec
End Sub

What do I need to insert in this code in order to make it populate the name field?

I am doing this because I don't want to have to enter in the name EVERY time I put in another date scheduled for an employee. Thanks for any help!

KellyJo

 
Now - this is the right forum for the question - look at my reply in thread709-920327 (which is not the right forum;-))

Roy-Vidar
 
I tried your code and it doesn't do anything. Can you tell me if I have ti right?

Private Sub Date_Scheduled_AfterUpdate()
DoCmd.GoToRecord , , acNewRec
Me!Name.DefaultValue = Me!Name.Value

End Sub

I don't know what the Me! part is for. Do I maybe have it wrong?
Thank you!
KellyJo
 
No, it probably won't when placed in that event after you've moved to a new record. Either try my suggestion, or at least place the line before moving to a new record.

Roy-Vidar
 
It's still not working.

me!txtName.DefaultValue=me!txtName.Value ' or
me!txtName.DefaultValue= chr(34) & me!txtName.Value & chr(34)

I changed the field name to ERName (my field), instead of txtName.

I didn't change anything else. I'm a bit daft at this, but do you have any suggestions?

KellyJo
 
Crystall ball is a bit clouded, I can't make out what "It's still not working" exactly means. The faq I referenced in the other thread #14 gives some hints...

Roy-Vidar
 
Code:
e Sub Date_Scheduled_AfterUpdate()
dim x as string 
x=me!ERName
DoCmd.GoToRecord , , acNewRec
me!ERName.defaultvalue=X

End Sub
I havent tried it but maybe this will work for you???
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top