Code to open a form and insert data

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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.
 
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
 
Back
Top