Solved

Querydef parameters

Posted on 2001-06-15
12
671 Views
Last Modified: 2008-03-10
A user can set two parameters on my form - one is text, the other a date.
An event opens a recordset for an existing query. This query is based on another query which takes 2 parameters - [myCourse] and [myDate] the data types of these parameters has been set in qryManualCount (which qryManualCount2 uses)
Code below;
Dim dbs As Database
Dim qdf1 As QueryDef

Set dbs = CurrentDb
Set qdf1 = dbs.QueryDefs![qryManualCount2]
qdf1.Parameters![myCourse] = Me!myCourse
qdf1.Parameters![myDate] = Me!txtDate

qdf1.OpenRecordset
Me!lstCourse.RowSource = qdf1.SQL

The problem is I get a dialog asking for a value for the [myDate] parameter even though I can see an appropriate value for that parameter when I inspect qdf1 using the debug window.

If I enter the date in the dialog I get the correct data, but cancelling/OKing the dialog means that nothing is returned.

Viv
0
Comment
Question by:vivn
  • 3
  • 3
  • 3
  • +3
12 Comments
 
LVL 1

Expert Comment

by:Doobs
Comment Utility
Every thing looks okay. The only thing you might try is

"qdf1.Execute"
rather than
"qdf1.OpenRecordset"

OR
Try decalring the parameter vaiables in the subroutine and setting them using the
"Set (......) = " etc

Doobs
0
 
LVL 6

Accepted Solution

by:
Mach1pro earned 50 total points
Comment Utility
See if this will react any differently

                    Set dbs = CurrentDb
                     Set qdf1 = dbs.QueryDefs![qryManualCount2]
                     qdf1.Parameters("myCourse") = Me!myCourse
                     qdf1.Parameters("myDate") = Me!txtDate
0
 

Author Comment

by:vivn
Comment Utility
qdf1.Execute is not valid because this is a select query.
I'm not sure setting the parameters differently will have any effect - I can see that they have been set by inspecting.
The alternative naming convention for the parameters had no effect.

0
 
LVL 5

Expert Comment

by:TheMek
Comment Utility
You might want to try formatting the date, so that it's clear to the program that it's a date field.

qdf1.Parameters![myDate] = Format(Me!txtDate, "mm/dd/yyyy")

Hope this helps,
   Erwin
0
 

Author Comment

by:vivn
Comment Utility
Tried formatting the date but this doesn't work either.
Judging by the inspector the program does recognise this as a date (before I set the parameter data type to date/time I was getting a data type mismatch error)
0
 
LVL 6

Expert Comment

by:Mach1pro
Comment Utility
vivn
Why not post the sql for your two queries?.  Maybe we could see something in there that you might be overlooking.
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

Author Comment

by:vivn
Comment Utility
SQL for first query (qryManualCount);
PARAMETERS [myCourse] Text, [myDate] DateTime;
SELECT tblSchedule.Course_id
FROM tblSchedule
WHERE (((tblSchedule.Course_id)=[myCourse]) AND ((tblSchedule.Course_date)>[myDate]) AND ((tblSchedule.Slot)="1") AND ((tblSchedule.Cancelled)="No"));
SQL for second query (qryManualCount2);
PARAMETERS [myCourse] Text, [myDate] DateTime;
SELECT qryManualCount.Course_id, Count(qryManualCount.Course_id) AS Total
FROM qryManualCount
GROUP BY qryManualCount.Course_id;
0
 
LVL 6

Expert Comment

by:Mach1pro
Comment Utility
Try removing the [myDate] parameter from your second query.  I don't see any reason why you need it and that may be what the program is calling.
0
 

Expert Comment

by:amp072397
Comment Utility
vivn:

You've logged in recently. Kindly return to and address this question.

thanks!
amp
community support moderator
0
 

Expert Comment

by:amp072397
Comment Utility
It's time to clean up this topic area and that means taking care of this question. Your options at this point are:

1. Award points to the Expert who provided an answer, or who helped you most. Do this by clicking on the "Accept Comment as Answer" button that lies above and to the right of the appropriate expert's name.

2. PAQ the question because the information might be useful to others, but was not useful to you. To use this option, you must state why the question is no longer useful to you, and the experts need to let me know if they feel that you're being unfair.

3.  Ask Community Support to help split points between participating experts.  Just comment here with details.

4.  Delete the question because it is of no value to you or to anyone else.  To use this option, you must state why the question is no longer useful to you, and the experts need to let me know if they feel that you're being unfair.

If you elect for option 2, 3 or 4, just post comment with details here and I'll take it from there. We also request that you review any other open questions you might have and update/close them.  Display all your question history from your Member Profile to view details.

PLEASE DO NOT AWARD THE POINTS TO ME.
____________________________________________

Hi Experts:

In the event that the Asker does not respond, I would very much appreciate your opinions as to which Expert ought to receive points (if any) as a result of this question.  Likewise, you can also suggest that I PAQ or delete the question.

Experts, please do not add further "answer" information to this question.  I will be back in about one week to finalize this question.

Thank you everyone.

amp
community support moderator
0
 

Expert Comment

by:amp072397
Comment Utility
vivn:

You have several open questions:

http://www.experts-exchange.com/jsp/qShow.jsp?qid=20242297
http://www.experts-exchange.com/jsp/qShow.jsp?qid=20136062
http://www.experts-exchange.com/jsp/qShow.jsp?qid=20088613
http://www.experts-exchange.com/jsp/qShow.jsp?qid=20027514

To assist you in your cleanup, I'm providing the following guidelines:

1.  Stay active in your questions and provide feedback whenever possible. Likewise, when feedback has not been provided by the experts, commenting again makes them receive an email notification, and they may provide you with further information. Experts have no other method of searching for questions in which they have commented, except manually.

2.  Award points by hitting the Accept Comment As Answer button located above and to the left of that expert's comment.

3.  When grading, be sure to read:
http://www.experts-exchange.com/jsp/cmtyQuestAnswer.jsp#3
to ensure that you understand the grading system here at EE. If you grade less than an A, you must explain why.

4.  Questions that were not helpful to you should be PAQ'd (stored in the database for their valuable content?even if not valuable to you) or deleted. To PAQ or delete a question, you must first post your intent in that question to make the experts aware. Then, if no experts object after three full days, you can post a zero-point question at community support to request deletion or PAQ. Please include the link(s) to the question(s).
CS:  http://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
At that point, a moderator can refund your points and PAQ or delete the question for you. The delete button does not work.

5.  If you fail to respond to this cleanup request, I must report you to the Community Support Administrator for further action.

Our intent is to get the questions cleaned up, and not to embarrass or shame anyone. If you have any questions or need further assistance at all, feel free to ask me in this question or post a zero-point question at CS. We are very happy to help you in this task!


thanks!
amp
community support moderator

2/6
0
 
LVL 5

Expert Comment

by:Netminder
Comment Utility
Per recommendation, force-accepted by
Netminder
CS Moderator
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

762 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now