troubleshooting Question

open form and load values

Avatar of petePrinter
petePrinterFlag for United Kingdom of Great Britain and Northern Ireland asked on
Microsoft Access
5 Comments1 Solution358 ViewsLast Modified:
i have frmenquiry that loads from a button click on another form.
it uses dmax to take the next number from a table.
User adds data in some fields and then closes the form which saves the data.
all ok.
The user would like the option to close the form and open another (Dmax adds 1) that contains two Pieces of data that is common from the first form.
i have set two variables PNumber and PDate to hold this in the event.

How do i load the new form so that it can access these variables and load the form to avoid retyping please?
Thanks for looking at this.

Private Sub cmdSave_NewCopy_Click()
Dim PNumber As String
Dim PDate As Date
Dim MysSQL As String
MySQL = "INSERT INTO tblEnquires([CustAutoNum],[contactID],[enqNumber],[enqCustRef],[enqDate],[enqDetail])SELECT" & Chr(34) & Me.txtCustAutoNum & Chr(34) & "," & Chr(34) & Me.txtcontactID & Chr(34) & "," & Chr(34) & Me.txtenqNumber & Chr(34) & "," & Chr(34) & Me.txtenqCustRef & Chr(34) & "," & Chr(34) & Me.txtenqDate & Chr(34) & "," & Chr(34) & Me.txtenqDetail & Chr(34) & ";"
DoCmd.SetWarnings (False)
DoCmd.SetWarnings (True)
PNumber = Me.txtenqCustRef
PDate = Me.txtenqDate
'MsgBox PNumber & " " & PDate
DoCmd.Close acForm, Me.Name, acSaveYes
DoCmd.OpenForm "frmEnquiry"
End Sub

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros