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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Opening report with combo box

Status
Not open for further replies.

mlocurci

MIS
Oct 17, 2001
210
US
I am want to use a form to allow the user to enter criteria for the report. Here is my unclick command.


Private Sub byAgent_Click()
If IsNull(Me.agentselect) Then
MsgBox "Please choose an agent"
Else
DoCmd.OpenReport "printevalbyagent", , , "[CSRName]= Me.agentselect"
End If

End Sub

Any ideas, why i can't get it to work.

 
Try this:

Private Sub byAgent_Click()
If IsNull(Me.agentselect) Then
MsgBox "Please choose an agent"
Else
DoCmd.OpenReport "printevalbyagent", , , "[CSRName]= '" + Me.agentselect + "'"
End If

End Sub Best Regards,
Mike
 
Hey guys, I'm also trying to open a report from a form but via textboxes instead. The two textboxes are startdate and enddate. I suppose "printevalbyagent" refers to the name of the report but what does "[CSRName]= '" mean? How do I open the report based on two values in the textboxes?

By the way, whenever I need to run the report (which is based on a select query and the select query is based on crosstab queries with criteria of the date fields set as >=Forms!Frmname!startdate and <=Forms!Frmname!enddate) but not via the form, I would be prompted to enter Forms!Frmname!startdate and Forms!Frmname!enddate. Is it possible to refer the values of startdate and enddate to the criteria of the report?
 
Tekila

The

[CSRName]= '&quot; + Me.agentselect + &quot;'&quot;

part is a where clause applied to the results of the reports underlying query. Best Regards,
Mike
 
Tekila, if your report is based on that query, and you try to OPEN the report, it's going to run the query. If the FORM that the query uses as the basis for the two criteria is not open, you get prompted to enter the values &quot;by hand&quot;, so to speak...

Report refers back to Query which refers back to Form




There are two ways to argue with a woman - neither one works.
Another free Access forum:
More Access stuff at
 
WildHare, I get what you mean so now I want to run the report from the form after I've fulfilled the select query's criteria by means of the values entered in startdate and enddate of the form. I've included the command to open the report in the On Click event of a command button but the report is not generated.

Please advise.
 
1) Does the query return any records? I know that sounds silly of me to ask, but obviously if the query doesn't return any records, you won't get a report.

2) You're not closing the form before you call the report are you? A closed form gathers no data, so to speak.

3) Does your OPENREPORT action set the mode to acNormal (printing) or acViewPreview (print preview) ??

4) I'm assuming your base table defined these start and end dates as DATE/TIME types. Did you set your text boxes as DATE datatypes too?

This is a very straightforward process, I've done it a million times, so it should work.




There are two ways to argue with a woman - neither one works.
Another free Access forum:
More Access stuff at
 
1. Yes if I try to view the results from the select query. In fact, the report returns the records too but not from the form of course.

I'm not sure if you fully understand how my crosstab queries, select query, form and report are linked. For the sake of clarification, let me go through this again in greater details. My aim is to generate a weekly report that is of crosstab format but with three value fields. Since Access does not allow multiple value fields, I've to create four crosstab queries and &quot;combine&quot; them in a select query. The date fields in the crosstabs are all >=Forms!Frmname!startdate AND <=Forms!Frmname!enddate. Following so far? I've also defined the query paramaters in all the queries. The weekly report is based on the select query and when I try to run the report, I would be prompted to enter the startdate and enddate and if my entries are valid, I would be able to view the records. I've achieved all of the above mentioned but couldn't generate the report from the form.

2. No, I don't think I've violated that.

3. DoCmd.OpenReport &quot;FCT Weekly&quot;, PrintMode

4. Yes.

 
Does the syntak change if instead of a drop down it becomes a text box?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top