Hi SunnySide,
Thanks for the follow up. So, you said:
Quote:
|
...the actual VBA that I am trying to run is more complicated, so I wanted to simplify it as much as possible to see if I was doing something wrong.
|
Hmm, well, in your previous post, you said: "But the value won't show", so I was assuming you were having a problem with a Query object itself. What I like to do in a situation like this is create an Access Query first and run it to test it, just to make sure it is working. Once I'm confident the Query is working, then I try to debug the VBA code.
So, the SQL statement you've provided me here (which is commented out with C# style comments, and not VBA style comments) is:
Code:
//SELECT PrevDate.CurrMonth, Month(Now()) AS PriorDate
//FROM PrevDate;
This SQL statement is obviously broken right off the bat, because it has slashes in it (again, these are C/C++/C# style comments). Also, it is important to understand whether you are using the DAO or ADO libraries in VBA and how you want to return that data...but in this case (for this simple statement), it won't make a difference...so I'm guessing it is a problem in your VBA code other than this statement.
So, to try to help you, I created a simple table and query in Access (based on the parameters you've provided above), and the following SQL statement should work (as you expected):
Code:
SELECT PrevDate.CurrMonth, Month(Now()) AS PriorDate
FROM PrevDate;
And, if I add that SQL statement to an Access Query object (and the proper Table exists), this Query does indeed return data in Access.
So, again, my guess is that there is a problem in your VBA code. From your original statement of:
Quote:
|
But the value won't show.
|
I had assumed you were trying to "see" the data in an Access query object. Could you elaborate a little more about what is happening when you believe that the value isn't being "shown"? Otherwise, at this point, I think the VBA code would be helpful too.
Anyway, I hope that helps, but if you have more questions, please let me know and I'll do the best I can with the information provided to help solve the problem...
Sincerely,