[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 721
  • Last Modified:

Querydef parameters

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
vivn
Asked:
vivn
  • 3
  • 3
  • 3
  • +3
1 Solution
 
DoobsCommented:
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
 
Mach1proCommented:
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
 
vivnAuthor Commented:
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
TheMekCommented:
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
 
vivnAuthor Commented:
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
 
Mach1proCommented:
vivn
Why not post the sql for your two queries?.  Maybe we could see something in there that you might be overlooking.
0
 
vivnAuthor Commented:
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
 
Mach1proCommented:
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
 
amp072397Commented:
vivn:

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

thanks!
amp
community support moderator
0
 
amp072397Commented:
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
 
amp072397Commented:
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
 
NetminderCommented:
Per recommendation, force-accepted by
Netminder
CS Moderator
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 3
  • 3
  • 3
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now