OpenReport where clause works only when hard-coded

I

iconicchris

Hi everyone -

I'm trying to use a where clause to open a report for preview - but it
only works when hard-coded - if I introduce a variable that looks
exactly the same as the hard-code, the where clause is ignored. Any
ideas what I'm doing wrong - or is this an Access issue? I'm using
Access 2003... Code follows:

Hard-coded:

DoCmd.OpenReport "RTS_SetReport", acViewPreview, , "[locationID]=3"

variable:
Dim stLinkCriteria As String
Dim location As String

location = lsdDDL.Column(0) 'retrieves a value from a combo box
stLinkCriteria = "[locationID]=" & location 'for this, stLinkCriteria
is "[locationID]=3"

DoCmd.OpenReport "RTS_SetReport", acViewPreview, , location

Thanks,
Chris
 
D

Duane Hookom

You create a value for stLinkCriteria but then you don't use it. Try:
DoCmd.OpenReport "RTS_SetReport", acViewPreview, , stLinkCriteria
 

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