Open a new form from Command button

jhansiblu

New member
Local time
Today, 13:18
Joined
Dec 5, 2007
Messages
6
I am trying to create a button that will open a a form and insert the Customer ID into the newly opened form. the customer table is the datasource for the customber form and when the button is clicked, I would like to open the Odrers form and auto insert the cutomer number of the record in the Customer form.
It tried:

Private Sub Orders_Click()
On Error GoTo Err_Orders_Click

ID.SetFocus
DoCmd.DoMenuItem acFormBar, acEditMenu, acCopy, , acMenuVer70
DoCmd.OpenForm "frm_orders"
DoCmd.GoToRecord , , acNewRec
CUST_ID.SetFocus
DoCmd.DoMenuItem acFormBar, acEditMenu, acPaste, , acMenuVer70
Me.Refresh

Exit_Orders_Click:
Exit Sub
Err_Orders_Click:
MsgBox Err.Description
Resume Exit_Orders_Click

I am getting the "object required" error.
 
Why not just do it this way:

DoCmd.OpenForm "frm_orders", acNormal, , , acFormAdd

Forms!frm_orders.CUST_ID = Me.ID
 
Thanks that worked!
 
Thanks that worked!

GladWeCouldHelp.png
 

Users who are viewing this thread

Back
Top Bottom