Query Help

D

dockeradz

I'm doing a OpenReport for generating labels with the following query:
[ComputerName] IN ('name1','name2')
And I always get whatever is in the first position. Here I would get name1.
I get no errors. What am I doing wrong?
 
D

Duane Hookom

What you have described is not a "query". It might be a Where Condition of
DoCmdOpenReport. Can you provide more code or context to your question?
 
D

dockeradz

It is the where condition of course. Here is the line of code:
DoCmd.OpenReport report,acViewPreview,,[ComputerName] IN ('name1','name2')

Duane Hookom said:
What you have described is not a "query". It might be a Where Condition of
DoCmdOpenReport. Can you provide more code or context to your question?

--
Duane Hookom
Microsoft Access MVP


dockeradz said:
I'm doing a OpenReport for generating labels with the following query:
[ComputerName] IN ('name1','name2')
And I always get whatever is in the first position. Here I would get name1.
I get no errors. What am I doing wrong?
 
D

Duane Hookom

Try add quotes around the where condition.

DoCmd.OpenReport report,acViewPreview,,"[ComputerName] IN ('name1','name2')"
--
Duane Hookom
Microsoft Access MVP


dockeradz said:
It is the where condition of course. Here is the line of code:
DoCmd.OpenReport report,acViewPreview,,[ComputerName] IN ('name1','name2')

Duane Hookom said:
What you have described is not a "query". It might be a Where Condition of
DoCmdOpenReport. Can you provide more code or context to your question?

--
Duane Hookom
Microsoft Access MVP


dockeradz said:
I'm doing a OpenReport for generating labels with the following query:
[ComputerName] IN ('name1','name2')
And I always get whatever is in the first position. Here I would get name1.
I get no errors. What am I doing wrong?
 
0

06»á¼Æ

dockeradz said:
I'm doing a OpenReport for generating labels with the following query:
[ComputerName] IN ('name1','name2')
And I always get whatever is in the first position. Here I would get name1.
I get no errors. What am I doing wrong?
 
D

dockeradz

The actual line is:
whereClause = "[ComputerName] IN ('name1','name2')"
DoCmd.OpenReport "MachineLabels", acViewPreview, , whereClause

whereClause is constructed by a loop. I have it displayed on the form for
debugging and it looks right, except no enclosing quotes. How could I put
enclosing quotes in the OpenReport statement?

Duane Hookom said:
Try add quotes around the where condition.

DoCmd.OpenReport report,acViewPreview,,"[ComputerName] IN ('name1','name2')"
--
Duane Hookom
Microsoft Access MVP


dockeradz said:
It is the where condition of course. Here is the line of code:
DoCmd.OpenReport report,acViewPreview,,[ComputerName] IN ('name1','name2')

Duane Hookom said:
What you have described is not a "query". It might be a Where Condition of
DoCmdOpenReport. Can you provide more code or context to your question?

--
Duane Hookom
Microsoft Access MVP


:

I'm doing a OpenReport for generating labels with the following query:
[ComputerName] IN ('name1','name2')
And I always get whatever is in the first position. Here I would get name1.
I get no errors. What am I doing wrong?
 
D

Duane Hookom

You don't need to use extra quotes if you actually use .., whereClause.

Please don't mislead us with statements like:
DoCmd.OpenReport report,acViewPreview,,[ComputerName] IN ('name1','name2')
when the actual code is:
whereClause = "[ComputerName] IN ('name1','name2')"
DoCmd.OpenReport report,acViewPreview,,whereClause

Have you tried add a debugging line like
Debug.Print whereClause
or
MsgBox "whereClause: " & whereClause

--
Duane Hookom
Microsoft Access MVP


dockeradz said:
The actual line is:
whereClause = "[ComputerName] IN ('name1','name2')"
DoCmd.OpenReport "MachineLabels", acViewPreview, , whereClause

whereClause is constructed by a loop. I have it displayed on the form for
debugging and it looks right, except no enclosing quotes. How could I put
enclosing quotes in the OpenReport statement?

Duane Hookom said:
Try add quotes around the where condition.

DoCmd.OpenReport report,acViewPreview,,"[ComputerName] IN ('name1','name2')"
--
Duane Hookom
Microsoft Access MVP


dockeradz said:
It is the where condition of course. Here is the line of code:
DoCmd.OpenReport report,acViewPreview,,[ComputerName] IN ('name1','name2')

:

What you have described is not a "query". It might be a Where Condition of
DoCmdOpenReport. Can you provide more code or context to your question?

--
Duane Hookom
Microsoft Access MVP


:

I'm doing a OpenReport for generating labels with the following query:
[ComputerName] IN ('name1','name2')
And I always get whatever is in the first position. Here I would get name1.
I get no errors. What am I doing wrong?
 
D

dockeradz

I got it. I'm reading in a list separated by line feeds and was splitting it
based on the linefeeds. They needed to be stripped off.

Thanks for your help. BTW I wasn't misleading.

Duane Hookom said:
You don't need to use extra quotes if you actually use .., whereClause.

Please don't mislead us with statements like:
DoCmd.OpenReport report,acViewPreview,,[ComputerName] IN ('name1','name2')
when the actual code is:
whereClause = "[ComputerName] IN ('name1','name2')"
DoCmd.OpenReport report,acViewPreview,,whereClause

Have you tried add a debugging line like
Debug.Print whereClause
or
MsgBox "whereClause: " & whereClause

--
Duane Hookom
Microsoft Access MVP


dockeradz said:
The actual line is:
whereClause = "[ComputerName] IN ('name1','name2')"
DoCmd.OpenReport "MachineLabels", acViewPreview, , whereClause

whereClause is constructed by a loop. I have it displayed on the form for
debugging and it looks right, except no enclosing quotes. How could I put
enclosing quotes in the OpenReport statement?

Duane Hookom said:
Try add quotes around the where condition.

DoCmd.OpenReport report,acViewPreview,,"[ComputerName] IN ('name1','name2')"
--
Duane Hookom
Microsoft Access MVP


:

It is the where condition of course. Here is the line of code:
DoCmd.OpenReport report,acViewPreview,,[ComputerName] IN ('name1','name2')

:

What you have described is not a "query". It might be a Where Condition of
DoCmdOpenReport. Can you provide more code or context to your question?

--
Duane Hookom
Microsoft Access MVP


:

I'm doing a OpenReport for generating labels with the following query:
[ComputerName] IN ('name1','name2')
And I always get whatever is in the first position. Here I would get name1.
I get no errors. What am I doing wrong?
 
D

Duane Hookom

Sorry, I should have said "confusing" rather than "misleading". "Misleading"
might carry a note of intention that I'm sure wasn't present.

--
Duane Hookom
Microsoft Access MVP


dockeradz said:
I got it. I'm reading in a list separated by line feeds and was splitting it
based on the linefeeds. They needed to be stripped off.

Thanks for your help. BTW I wasn't misleading.

Duane Hookom said:
You don't need to use extra quotes if you actually use .., whereClause.

Please don't mislead us with statements like:
DoCmd.OpenReport report,acViewPreview,,[ComputerName] IN ('name1','name2')
when the actual code is:
whereClause = "[ComputerName] IN ('name1','name2')"
DoCmd.OpenReport report,acViewPreview,,whereClause

Have you tried add a debugging line like
Debug.Print whereClause
or
MsgBox "whereClause: " & whereClause

--
Duane Hookom
Microsoft Access MVP


dockeradz said:
The actual line is:
whereClause = "[ComputerName] IN ('name1','name2')"
DoCmd.OpenReport "MachineLabels", acViewPreview, , whereClause

whereClause is constructed by a loop. I have it displayed on the form for
debugging and it looks right, except no enclosing quotes. How could I put
enclosing quotes in the OpenReport statement?

:

Try add quotes around the where condition.

DoCmd.OpenReport report,acViewPreview,,"[ComputerName] IN ('name1','name2')"
--
Duane Hookom
Microsoft Access MVP


:

It is the where condition of course. Here is the line of code:
DoCmd.OpenReport report,acViewPreview,,[ComputerName] IN ('name1','name2')

:

What you have described is not a "query". It might be a Where Condition of
DoCmdOpenReport. Can you provide more code or context to your question?

--
Duane Hookom
Microsoft Access MVP


:

I'm doing a OpenReport for generating labels with the following query:
[ComputerName] IN ('name1','name2')
And I always get whatever is in the first position. Here I would get name1.
I get no errors. What am I doing wrong?
 

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