Code to open a form and insert data

M

Mike

Hi,
I have a form with blank text boxes for values to be typed (MemberID Number)
I then want a command Button to open an existing form in add
mode(frmBookings) and insert the value from the text box on the original form
into one of the fields (MemeberID) in (frmBookings).
Getting the form to open in add mode is no problem its the inserting value
part that i'm struggling with.
Any help would be greatly appreciated.
 
M

Marshall Barton

Mike said:
I have a form with blank text boxes for values to be typed (MemberID Number)
I then want a command Button to open an existing form in add
mode(frmBookings) and insert the value from the text box on the original form
into one of the fields (MemeberID) in (frmBookings).
Getting the form to open in add mode is no problem its the inserting value
part that i'm struggling with.


Use the OpenForm method's OpenArgs argument to pass the
value to the form. The form's Load event can then set the
field to the value.

In the command button's Click event:
DoCmd.OpenForm "frmBookings", _
DataMode:= acFormAdd, _
OpenArgs:= Me.MemberID

In frmBookings Load event:
Me.MemberID = Me.OpenArgs
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top