Solved

problems with union query

Posted on 2012-04-05
6
399 Views
Last Modified: 2012-04-05
I have the following union query behind a dropdown in access2007.

SELECT "(All)" As Section FROM tblCoversheets UNION Select [Section] FROM tblCoversheets WHERE CoverSheetDate = #"  & Me.cmbDateTime & "#"

Me.cmbDateTime comes from a dropdown that list the coverheetdates

When I click on the combobox that should list the sections I get the following
error: the microsoft database engine could not find the object 'coversheetdate = #" & Me.cmdDateTime & "&".

I have no idea why I'm getting this error.
Any help is most appreciated.
0
Comment
Question by:BauwensER
6 Comments
 
LVL 77

Expert Comment

by:peter57r
ID: 37809885
Where exactly is this sql expression located ?  The expression does not make sense as it is posted here because the combination of " being used render it invalid.
0
 

Author Comment

by:BauwensER
ID: 37809918
It is in the rowsource of the 2nd drop-down on a form.
Basicaly first the user select the date of the coversheet (1st drop-down) then
the user select the section(2nd drop-down).
I hope this is clear enough..
0
 

Expert Comment

by:Shiv_Sg
ID: 37809927
I am not an Access Expert but I see this double-quote (if it is a double-quote not 2 single quotes) WHERE CoverSheetDate = #" hanging in the air without an end quote, I would guess it should be

WHERE CoverSheetDate= "#"
0
The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

 

Author Comment

by:BauwensER
ID: 37809949
I have now this as rowsource:

SELECT "(All)" As Section FROM tblCoversheets UNION Select [Section] FROM tblCoversheets WHERE CoverSheetDate = "#" & Me!cmbDateTime & "#" ORDER BY Section;

but when I open the dropdown I get a pop-up with Enter Parameter ValueMe!cmbDateTime
0
 
LVL 39

Accepted Solution

by:
als315 earned 500 total points
ID: 37809955
In rowsource you can't use Me!cmbDateTime. Use Combobox name without Me
Why you need there union query if both queries are from one table?
0
 

Author Comment

by:BauwensER
ID: 37809966
I just tried that but then I get the message that query is too complex to be evaluated.
(frustrating). I need the union because I need the string(All) so that users can print ALL coversheets if they need so.
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Outlook Free & Paid Tools
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question