Command Button String help

  • Thread starter LT Larry via AccessMonster.com
  • Start date
L

LT Larry via AccessMonster.com

I am trying to link a command button on a form to a report using the
following string:

Private Sub Command36_Click()
On Error GoTo Err_Command36_Click

Dim StrWhere As String
If IsNull(Text33) = False Then
StrWhere = "LastName='" & [Forms]![Emply Reports]![Text33] & ""
End If
DoCmd.OpenReport "Patrol Quarterly Use of Force Report1", acPreview, ,
StrWhere

And I am getting a Syntax error In String'(LastName='test)'
Test is the sample name I am using

Any Ideas or am I way off base???

Thanks in advance
 
F

fredg

I am trying to link a command button on a form to a report using the
following string:

Private Sub Command36_Click()
On Error GoTo Err_Command36_Click

Dim StrWhere As String
If IsNull(Text33) = False Then
StrWhere = "LastName='" & [Forms]![Emply Reports]![Text33] & ""
End If
DoCmd.OpenReport "Patrol Quarterly Use of Force Report1", acPreview, ,
StrWhere

And I am getting a Syntax error In String'(LastName='test)'
Test is the sample name I am using

Any Ideas or am I way off base???

Thanks in advance

You left out a single quote.
StrWhere = "LastName=' " & [Forms]![Emply Reports]![Text33] & " "

It should be:
StrWhere = "LastName=' " & [Forms]![Emply Reports]![Text33] & " ' "

Quotes expanded for clarity. Remove the added spaces.
 

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