By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,318 Members | 2,116 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,318 IT Pros & Developers. It's quick & easy.

Passing Value from the form to a report query

P: n/a
I have to pass a date from a form to a report query. I have written a
query that works fine when I execute from SQL view, But I dont know
how to pass a value from the form to this query.

SELECT Production.Production
FROM Production
WHERE (((Production.Date)=Forms!ReportForm!reportDate) And
((Production.ShiftName)="Shift1"));
I search so many mails in this group, but I didn't find a simple
answer to my problem.

Thanks

Mike
Nov 13 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
I'm not sure what the problem is, but if the query runs fine then the
report should also. Are you closing the form when you run the report?
If so, is hiding the form before opening the report an option? Will you
be using the form again?

Mike wrote:
I have to pass a date from a form to a report query. I have written a
query that works fine when I execute from SQL view, But I dont know
how to pass a value from the form to this query.

SELECT Production.Production
FROM Production
WHERE (((Production.Date)=Forms!ReportForm!reportDate) And
((Production.ShiftName)="Shift1"));
I search so many mails in this group, but I didn't find a simple
answer to my problem.

Thanks

Mike


--
--------------------------------------
Chris Moore
cdmwebs [at] no_spam_hotmail [dot] com
http://cdmwebs.com
Nov 13 '05 #2

P: n/a
Chris,

Thanks for the response.

Query runs fine in the Sql view because it prompts for date which I
enter and get the
desired output from the undermentioned query.
SELECT Production.Production
FROM Production
WHERE (((Production.Date)=Forms!ReportForm!reportDate) And
((Production.ShiftName)="Shift1"));

However, I need to pass this value from a form(text field) to this
query and once I click
on the show report button in the form, form closes and report pops up
with the results base on above query.

Actually, the application that I am trying to develop will need much
more complicated query
than the one shown above, but I have to go step by step.
Thanks

Mike

Chris Moore <cdmwebs@no_spam.hotmail.com> wrote in message news:<40F5CFBF.30307@no_spam.hotmail.com>...
I'm not sure what the problem is, but if the query runs fine then the
report should also. Are you closing the form when you run the report?
If so, is hiding the form before opening the report an option? Will you
be using the form again?

Mike wrote:
I have to pass a date from a form to a report query. I have written a
query that works fine when I execute from SQL view, But I dont know
how to pass a value from the form to this query.

SELECT Production.Production
FROM Production
WHERE (((Production.Date)=Forms!ReportForm!reportDate) And
((Production.ShiftName)="Shift1"));
I search so many mails in this group, but I didn't find a simple
answer to my problem.

Thanks

Mike

Nov 13 '05 #3

P: n/a
Mike
However, I need to pass this value from a form(text field) to this
query and once I click
on the show report button in the form, form closes and report pops up ********* with the results base on above query.


As Chris already told you, don't close the form but hide it or do otherwise.
You can also close the form when the report is closed.

--
Hope this helps
Arno R

Nov 13 '05 #4

P: n/a

I change the command and now form does not close.
But I dont know why still

Forms!ReportForm!reportDate (where reportDate is a text field) is not
able to pass the value from the form to the report query.

SELECT Production.Production
FROM Production
WHERE (((Production.Date)=Forms!ReportForm!reportDate) And
((Production.ShiftName)="Shift1"));

Is there any way to test what is being passed to the where clause in the
Form.

Please help I am stuck on this from 2 days...

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #5

P: n/a
Sure there is... Just stick a MsgBox in right before the report
opens. In the report's open event, add:

MsgBox "The value is: " & Forms!ReportForm!reportDate

and see what you get.
Chris

Mike Panwar <mp******@yahoo.com> wrote in message news:<40**********************@news.newsgroups.ws> ...
I change the command and now form does not close.
But I dont know why still

Forms!ReportForm!reportDate (where reportDate is a text field) is not
able to pass the value from the form to the report query.

SELECT Production.Production
FROM Production
WHERE (((Production.Date)=Forms!ReportForm!reportDate) And
((Production.ShiftName)="Shift1"));

Is there any way to test what is being passed to the where clause in the
Form.

Please help I am stuck on this from 2 days...

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


--
Chris Moore
cdmwebs [at] no_spam_hotmail [dot] com
http://cdmwebs.com
Nov 13 '05 #6

P: n/a
One other thing, Mike. I just read your post again and I see that
you're passing a date to your report. Make sure you wrap the date
with pound signs (#) in your code or use the CDate function in your
SQL.

WHERE (((Production.Date)=CDate(Forms!ReportForm!reportD ate)) And

Chris

Mike Panwar <mp******@yahoo.com> wrote in message news:<40**********************@news.newsgroups.ws> ...
I change the command and now form does not close.
But I dont know why still

Forms!ReportForm!reportDate (where reportDate is a text field) is not
able to pass the value from the form to the report query.

SELECT Production.Production
FROM Production
WHERE (((Production.Date)=Forms!ReportForm!reportDate) And
((Production.ShiftName)="Shift1"));

Is there any way to test what is being passed to the where clause in the
Form.

Please help I am stuck on this from 2 days...

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


--
Chris Moore
cdmwebs [at] no_spam_hotmail [dot] com
http://cdmwebs.com
Nov 13 '05 #7

P: n/a
Thanks Chris!!
I was able to solve the problem with your help.

Mike

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.