A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Setting Up & Running Reports
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Access asks for parameters



 
 
Thread Tools Display Modes
  #1  
Old March 9th, 2010, 08:19 AM posted to microsoft.public.access.reports
John F[_2_]
external usenet poster
 
Posts: 18
Default Access asks for parameters

I have aform with [date1] , [date2] and [print] controls on it.
I want to retrieve data from several tables using a query.
The query contains [datespan] Between [date1] And [date2].
The Print button on the Forms has a "where clause" ( [datespan]=[date1] And
[datespan]=[date2].
Also there is a graph to be printed that has the same sorting as the where
clause.
I get 3 pop-ups asking for date1 and date2. If I give the dates three times,
I get the print. Otherwise I get nothing.

If I re-type "date1" and "date2" in the form's text boxes (design view), the
result is OK. Until next time I log on - then it's all over again.

Is there somewhere Access does not recognize the field values?
  #2  
Old March 9th, 2010, 09:48 AM posted to microsoft.public.access.reports
Allen Browne
external usenet poster
 
Posts: 11,706
Default Access asks for parameters

If you want the query to read the text boxes on the form, you need to give
the full reference, such as:
[datespan] Between [Forms].[Form1].[date1] And [Forms].[Form1].[date2]
To ensure the query understands the data type correctly:
a) Set the Format property of both text boxes to General Date
b) Declare the parameters in the query. Open the Parameters box
(menu/ribbon), and enter 2 rows:
[Forms].[Form1].[date1] Date/Time
[Forms].[Form1].[date2] Date/Time

If you are building the WHERE clause, you need to concatenate the dates from
the form into the string, e.g.:
Dim strWhere As String
Const strcJetDate = "#\mm\/dd\/yyyy\#"
If IsDate(Me.date1) And IsDate(Me.date2) Then
strWhere = "(datespan = " & Format(Me.date1, strcJetDate) & _
") AND (datespan " & Format(Me.date2+1, strcJetDate) & ")"
End If

Do not change the date format above to match your regional settings. More
info:
http://allenbrowne.com/ser-36.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.


"John F" wrote in message
news
I have aform with [date1] , [date2] and [print] controls on it.
I want to retrieve data from several tables using a query.
The query contains [datespan] Between [date1] And [date2].
The Print button on the Forms has a "where clause" ( [datespan]=[date1]
And
[datespan]=[date2].
Also there is a graph to be printed that has the same sorting as the where
clause.
I get 3 pop-ups asking for date1 and date2. If I give the dates three
times,
I get the print. Otherwise I get nothing.

If I re-type "date1" and "date2" in the form's text boxes (design view),
the
result is OK. Until next time I log on - then it's all over again.

Is there somewhere Access does not recognize the field values?


  #3  
Old March 9th, 2010, 11:06 AM posted to microsoft.public.access.reports
John F[_2_]
external usenet poster
 
Posts: 18
Default Access asks for parameters

Thanks Allen,
it seems like the trick was to be consequent on the date format.

John

"Allen Browne" wrote:

If you want the query to read the text boxes on the form, you need to give
the full reference, such as:
[datespan] Between [Forms].[Form1].[date1] And [Forms].[Form1].[date2]
To ensure the query understands the data type correctly:
a) Set the Format property of both text boxes to General Date
b) Declare the parameters in the query. Open the Parameters box
(menu/ribbon), and enter 2 rows:
[Forms].[Form1].[date1] Date/Time
[Forms].[Form1].[date2] Date/Time

If you are building the WHERE clause, you need to concatenate the dates from
the form into the string, e.g.:
Dim strWhere As String
Const strcJetDate = "#\mm\/dd\/yyyy\#"
If IsDate(Me.date1) And IsDate(Me.date2) Then
strWhere = "(datespan = " & Format(Me.date1, strcJetDate) & _
") AND (datespan " & Format(Me.date2+1, strcJetDate) & ")"
End If

Do not change the date format above to match your regional settings. More
info:
http://allenbrowne.com/ser-36.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.


"John F" wrote in message
news
I have aform with [date1] , [date2] and [print] controls on it.
I want to retrieve data from several tables using a query.
The query contains [datespan] Between [date1] And [date2].
The Print button on the Forms has a "where clause" ( [datespan]=[date1]
And
[datespan]=[date2].
Also there is a graph to be printed that has the same sorting as the where
clause.
I get 3 pop-ups asking for date1 and date2. If I give the dates three
times,
I get the print. Otherwise I get nothing.

If I re-type "date1" and "date2" in the form's text boxes (design view),
the
result is OK. Until next time I log on - then it's all over again.

Is there somewhere Access does not recognize the field values?


.

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 04:59 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.