Pass data to new form

  • Thread starter mattc66 via AccessMonster.com
  • Start date
M

mattc66 via AccessMonster.com

When the below code opens a new form I want it to pass the Me.CUSTOMER_NUM =
stCustId. When the new form is open the Customer_num field is blank.

Private Sub cmdNote_Click()
On Error GoTo Err_cmdNote_Click

Dim stDocName As String
Dim stLinkCriteria As String
Dim stCustId As String


stDocName = "frmNotes"
stCustId = Me.CUSTOMER_NUM


If [NotesID] >= 1 Then
stLinkCriteria = "[NotesID]=" & Me![NotesID]
'stLink = "[GroupID]=" & Me![GroupID]

DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
DoCmd.OpenForm stDocName, , , , acFormAdd
Me.CUSTOMER_NUM = stCustId

'DoCmd.OpenForm stDocName
End If

Exit_cmdNote_Click:
Exit Sub

Err_cmdNote_Click:
msgbox Err.Description
Resume Exit_cmdNote_Click

End Sub
 
B

Bob Quintal

When the below code opens a new form I want it to pass the
Me.CUSTOMER_NUM = stCustId. When the new form is open the
Customer_num field is blank.

Private Sub cmdNote_Click()
On Error GoTo Err_cmdNote_Click

Dim stDocName As String
Dim stLinkCriteria As String
Dim stCustId As String


stDocName = "frmNotes"
stCustId = Me.CUSTOMER_NUM


If [NotesID] >= 1 Then
stLinkCriteria = "[NotesID]=" & Me![NotesID]
'stLink = "[GroupID]=" & Me![GroupID]

DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
DoCmd.OpenForm stDocName, , , , acFormAdd
Me.CUSTOMER_NUM = stCustId

'DoCmd.OpenForm stDocName
End If

Exit_cmdNote_Click:
Exit Sub

Err_cmdNote_Click:
msgbox Err.Description
Resume Exit_cmdNote_Click

End Sub

Me.CUSTOMER_NUM = stCustId
must be changed to
Forms!frmNotes.CUSTOMER_NUM = Me.CUSTOMER_NUM

Me is a shortcut for the form in which the code resides.
 
M

mattc66 via AccessMonster.com

Thanks that did it.

Bob said:
When the below code opens a new form I want it to pass the
Me.CUSTOMER_NUM = stCustId. When the new form is open the
[quoted text clipped - 32 lines]

Me.CUSTOMER_NUM = stCustId
must be changed to
Forms!frmNotes.CUSTOMER_NUM = Me.CUSTOMER_NUM

Me is a shortcut for the form in which the code resides.
 

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