In the following VBA, I cannot get my first form to open a popup form, using two matching values from each form. In the future, I may need to use more than two matching values between the two forms, and the use of the word
And I hope to avoid. If I had several matches required between two forms it may be cumbersome. As it is, I did write this code; I customized it from some vba code from a database template.
Currently, I have two forms, whose source is the exact same SQL statement. The first form is a "continous" and the next is a "single" mode popup. On the first form, I am using objectA (a textbox with a number datatype, from the table). ObjectA is a command
button on the first form. txt1 and txt2 are textboxes, each attached to different field in the database; they are both number datatypes.
Private Sub cmdObjectA_Click()
On Error GoTo Err_cmdObjectA_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "myPopupForm"
stLinkCriteria = "[txt1]=" & Me![txt1] And "[txt2]=" & Me![txt2]
' DoCmd.Close
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_cmdObjectA_Click:
Exit Sub
Err_cmdObjectA_Click:
MsgBox Err.Description
Resume Exit_cmdObjectA_Click
End Sub
==============
example of many matches to open a popup form, becoming cumbersome
stLinkCriteria = "[txt1]=" & Me![txt1] And "[txt2]=" & Me![txt2]
And "[txt3]=" & Me![txt3] And "[txt4]=" & Me![txt4]
what if a textbox is blank, like [txt4]?
==============
VWP1 20120222 17:30