Syntax Operator Problem

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

Guest

this is one of them small problems that i can just never figure out. The
following code should simply open the report where the values are equal. I
can find them manually so i know they are deffinately linked correctly
however i think its a problem with the various operators to call the
variable. MAny thanks for any help in advance.

Dim LinkRequest As String
LinkRequest = [Forms]![frmRequest]![NewRequestID]

DoCmd.OpenReport "rptRequestHardCopy", acViewPreview, , "[NewRequestID] = &
LinkRequest &"
 
DoCmd.OpenReport "rptRequestHardCopy", acViewPreview, , _
"[NewRequestID] = & LinkRequest &"

The criterion part is wrong: you need to pass the contents of the
LinkRequest string, not its name. Try this:

DoCmd.OpenReport "rptRequestHardCopy", acViewPreview, , _
"[NewRequestID] = " & LinkRequest



If the NewRequestID field is a Text type, then you'll need the
appropriate delimiters:

LinkRequest = Chr$(34) &
Replace(Forms!frmRequest!NewRequestID, chr$(34), String(34,2)) & _
Chr$(34)

Hope that helps


Tim F
 
Thanks Tim. That is spot on, works great now thanks to you. Shame you can't
buy people pints over this thing.

Tim Ferguson said:
DoCmd.OpenReport "rptRequestHardCopy", acViewPreview, , _
"[NewRequestID] = & LinkRequest &"

The criterion part is wrong: you need to pass the contents of the
LinkRequest string, not its name. Try this:

DoCmd.OpenReport "rptRequestHardCopy", acViewPreview, , _
"[NewRequestID] = " & LinkRequest



If the NewRequestID field is a Text type, then you'll need the
appropriate delimiters:

LinkRequest = Chr$(34) &
Replace(Forms!frmRequest!NewRequestID, chr$(34), String(34,2)) & _
Chr$(34)

Hope that helps


Tim F
 
Thanks Tim. That is spot on, works great now thanks to you. Shame you can't
buy people pints over this thing.

Har! That's what we need! A virtual pub to let people know how much we
appreciate their help by buying them virtual pints!

Here's a pint for you, Mike, for a great idea!

Regards,
RD
 
Back
Top