Click to See Complete Forum and Search --> : Report Properties [Resolved]
ober0330
Dec 10th, 2003, 08:58 AM
Is there any way to change the query that is run for a report through VBA?
Currently a report of mine runs a certain query to populate the report. Depending on certain conditions, I want to change the query that is used for that report.
ober0330
Dec 10th, 2003, 09:46 AM
Also, does the Order By clause not work for reports? I have it in my query and if you run the query seperately, it works fine. But when I use the query with a function, it doesn't put them in order.
salvelinus
Dec 10th, 2003, 10:52 AM
How are you making your queries? In Access or through building SQL in VB code? I have a project where some queries are created in Access, put in a macro, which is then invoked by code as well.
Wouldn't it be easier to write your own apps instead of dealing with others code? I know it would be for me.
ober0330
Dec 10th, 2003, 10:56 AM
I'm building the queries in SQL through the VBA editor.
I've solved the first two problems, but now I'm having another problem... after I create the SQL statement, I write it out to a query so that it can be used by the "DoCmd.OpenReport" call. But whenever it writes the Access query, it puts extra parenthesis "()" around the query and then it doesn't work right. If I go into the query and delete the outermost parenthesis, the query works fine. But I have to create it on the fly and the stupid thing keeps putting those "()" in there.
:mad:
salvelinus
Dec 10th, 2003, 11:33 AM
Are you adding parantheses when you build the query? If so, try leaving a pair off. I've noticed that if you use the design view to build a query, Access throws a bunch of parantheses in when you look at the query in SQL view.
ober0330
Dec 10th, 2003, 11:54 AM
I'm not putting any parens in when I create the statement. It puts them all in by itself and hence screws up my report!
ober0330
Dec 10th, 2003, 01:15 PM
Nevermind, I got it :D
Stupid Access is f-ing picky. :eek:
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.