link criteria VB

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

Guest

I have a field in a form that when the data is changed I'd like another form
to open. I have set the 'dirty' event and had no problem when linking the
form with only one field. But, don't know how to write the code with two
fields linked. The code I tried to use follows. Can someone help me correct
it.
Thx much
=============================
Private Sub ECLevel_Dirty(Cancel As Integer)
Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmECLevelChanges"

stLinkCriteria = "[PN]=" & "'" & Me![PN] & "'" And "[CustPO]=" & "'" &
Me![CustPO] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria


End Sub
 
I have a field in a form that when the data is changed I'd like another form
to open. I have set the 'dirty' event and had no problem when linking the
form with only one field. But, don't know how to write the code with two
fields linked. The code I tried to use follows. Can someone help me correct
it.

I'd really use the AfterUpdate event of the control instead; it fires when the
value in the control has been changed. Something like

Private Sub ECLevel_AfterUpdate()
Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmECLevelChanges"

stLinkCriteria = "[PN]='" & Me![PN] & "' And [CustPO]='" &
Me![CustPO] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria


End Sub

This pieces together five string constants or variables:

[PN]='
<whatever is in Me![PN]>
' And [CustPO] = '
<whatever is in Me![CustPO]>
'

The end result is something like

[PN]='A123145' And [CustPO]='PO3315'


John W. Vinson [MVP]
 
Thank you - I'll try writing it per your example. Thank you for your help


John W. Vinson said:
I have a field in a form that when the data is changed I'd like another form
to open. I have set the 'dirty' event and had no problem when linking the
form with only one field. But, don't know how to write the code with two
fields linked. The code I tried to use follows. Can someone help me correct
it.

I'd really use the AfterUpdate event of the control instead; it fires when the
value in the control has been changed. Something like

Private Sub ECLevel_AfterUpdate()
Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmECLevelChanges"

stLinkCriteria = "[PN]='" & Me![PN] & "' And [CustPO]='" &
Me![CustPO] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria


End Sub

This pieces together five string constants or variables:

[PN]='
<whatever is in Me![PN]>
' And [CustPO] = '
<whatever is in Me![CustPO]>
'

The end result is something like

[PN]='A123145' And [CustPO]='PO3315'


John W. Vinson [MVP]
 
Back
Top