Open a Report froma Form by a drop down

K

Kat

I am getting an error message that I can't figuar out. I have a form where
there is a combox that has a list of peopel (CSR) that are assigned to a
ticket. I want to use the drop down to select a report for who ever name is
selected in the drop down. Here is the String:

Private Sub CmdAssignedTo_Click()
On Error GoTo Err_CmdAssignedTo_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "ActivebyAssigned"

stLinkCriteria = "[CSR] = " & "" & Me![CmbAssignedtoName] & ""
DoCmd.OpenReport stDocName, acViewPreview, , stLinkCriteria

DoCmd.SelectObject acForm, "Switchboard", Yes
DoCmd.Minimize
DoCmd.SelectObject acReport, "ActivebyAssigned", Yes

Exit_CmdAssignedTo_Click:
Exit Sub

Err_CmdAssignedTo_Click:
MsgBox Err.Description
Resume Exit_CmdAssignedTo_Click

End Sub

Here is the error message:

Syntax error (missing operator) in query expression '([CSR] = Fred Sluspke)"
 
K

Klatuu

When posting a message, it is always helpful to post the error number and on
which line the error occurred. Fortunately, this one is easy. This line is
incorrect:
stLinkCriteria = "[CSR] = " & "" & Me![CmbAssignedtoName] & ""

It should be:
stLinkCriteria = "[CSR] = """ & Me![CmbAssignedtoName] & """"
 

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