Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA routine that uses 3 queries that have a user input

Status
Not open for further replies.

Delindan

MIS
May 27, 2011
203
US
I have a routine that is pulling data from 3 queries that require a date input from the user. Each of these queries use the date parameter to calculate budgeted, actual and forecasted salaries. Individually, all of these queries work fine.

My problem comes when I try to use them to export data. I get an error 3061...too few parameters on a line "Set RSBudget = DB.OpenRecordset("Budget", dbOpenSnapshot)" where I'm opening the first query. I've used this syntax lots of times before and suspect it is the date input that is the problem. The way I set it up, I have the user input defined as [Forms]![Dollar Export].[txtStart] in all three queries and a text input on the face of the form called txtStart. Seems like it should work although I have never referenced a query that had a user input like that so I'm sure I'm not doing something right. Any ideas?

Thanks!
 



hi,

What application, please?

If you are coding in MS Access VBA, then forum705 might give you better results.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
So, I guess you're usibg msaccess:
Code:
Dim qdf As DAO.QueryDef
Dim prm As DAO.Parameter
Set qdf = DB.QueryDefs("Budget")
For Each prm In qdf.Parameters
  prm.Value = Eval(prm.Name)
Next prm
Set RSBudget = qdf.OpenRecordset

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Sorry...yes I'm using Access and probably in the wrong forum. Thanks for the suggestion. I will try what you've suggested and let you know.
 
I'm getting a user defined type not set error on the line Dim prm As DAO.ParameterSet
 
Sorry, but I see NO ParameterSet in my posted code ...
 
Duh... even after you posted that it took me a bit to see my error. Anyway, I have never used that syntax so it will take me a bit to understand what I just put in however it worked! Thanks so much!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top