Solved

problems with union query

Posted on 2012-04-05
6
419 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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 

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 40

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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

696 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