G
Guest
Hi there! Using A02 on XP. Thought I had it. Can't get it to work. Probably
something SO simple. I have a text field on my form [PolNum] and want to open
a query of records related to [PolNum] (I have the field in my query also).
The quotes get me every time!
Private Sub Command41_Click()
On Error GoTo Err_Command41_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "qEnrollFormsByPlan#"
stLinkCriteria = "PolNum=""" & Me![PolNum] & """"
DoCmd.OpenQuery stDocName, acNormal, acReadOnly
Exit_Command41_Click:
Exit Sub
Err_Command41_Click:
MsgBox Err.Description
Resume Exit_Command41_Click
End Sub
Compile on above runs fine but when I click the button, I get ALL the
records. Ugh!
Also tried this line instead of all that above:
DoCmd.OpenQuery "qEnrollFormsByPlan#", acViewPreview, acReadOnly, PolNum
= Me.PolNum
On Compile, I get this error - Compile Error: wrong number of arguments or
invalid property assignment. So I can't even test this one.
Sorry to bother you guys with this, I should know these better by now but
setting the criteria quotes kills me. Any help or advice would be greatly
appreciated. Thanks in advance for your time.
something SO simple. I have a text field on my form [PolNum] and want to open
a query of records related to [PolNum] (I have the field in my query also).
The quotes get me every time!
Private Sub Command41_Click()
On Error GoTo Err_Command41_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "qEnrollFormsByPlan#"
stLinkCriteria = "PolNum=""" & Me![PolNum] & """"
DoCmd.OpenQuery stDocName, acNormal, acReadOnly
Exit_Command41_Click:
Exit Sub
Err_Command41_Click:
MsgBox Err.Description
Resume Exit_Command41_Click
End Sub
Compile on above runs fine but when I click the button, I get ALL the
records. Ugh!
Also tried this line instead of all that above:
DoCmd.OpenQuery "qEnrollFormsByPlan#", acViewPreview, acReadOnly, PolNum
= Me.PolNum
On Compile, I get this error - Compile Error: wrong number of arguments or
invalid property assignment. So I can't even test this one.
Sorry to bother you guys with this, I should know these better by now but
setting the criteria quotes kills me. Any help or advice would be greatly
appreciated. Thanks in advance for your time.