Despair

G

Georgi

I open a report which opens a form for criteria for
report (dates. The report lists all calls between 2 dates
(entered through 2 unbound text boxes. I've added a combo
box but am unable to find a way that the report will only
select calls to the Company picked from the combo box.

Criteria used in query = Between [forms]![CallDialog]!
[StartDate] And [forms]![CallDialog]![EndDate]
Print Preview button uses code Me.Visible = False
Combo box is called cboCompanyName

Please help this is driving me insane.
Georgi
 
T

Treebeard

Georgi said:
I open a report which opens a form for criteria for
report (dates. The report lists all calls between 2 dates
(entered through 2 unbound text boxes. I've added a combo
box but am unable to find a way that the report will only
select calls to the Company picked from the combo box.

Criteria used in query = Between [forms]![CallDialog]!
[StartDate] And [forms]![CallDialog]![EndDate]
Print Preview button uses code Me.Visible = False
Combo box is called cboCompanyName

Please help this is driving me insane.
Georgi

Georgi,

How do the dates get from the combo box (cboCompanyName) to the unbound text
boxes? Do you have the proper code in the AfterUpdate event of the comboBox?

If I were you, I'd take the criteria out of the Query . Use this in the
OnClick event of the PrintPreview Button:

Dim strCriteria As String, dteStartDate, dteEndDate As Date

If IsDate(Me.StartDate) And IsDate(me.EndDate) then
dteStartDate = Me.StartDate
dteEndDate = Me.EndDate
strCriteria = "[DateFieldName] >= #" & Format$(dteStartDate, "mm/dd/yyyy") &
"# AND [DateFieldName] <= #" & Format$(dteEndDate, "mm/dd/yyyy") & "#"
DoCmd.Close
DoCmd.OpenReport "YourReportName", acViewPreview, , strCriteria
DoCmd.SelectObject acReport, "YourReportName, False

Else
msgBox "Invalid Dates!"

End If
 
D

Dirk Goldgar

Georgi said:
I open a report which opens a form for criteria for
report (dates. The report lists all calls between 2 dates
(entered through 2 unbound text boxes. I've added a combo
box but am unable to find a way that the report will only
select calls to the Company picked from the combo box.

Criteria used in query = Between [forms]![CallDialog]!
[StartDate] And [forms]![CallDialog]![EndDate]
Print Preview button uses code Me.Visible = False
Combo box is called cboCompanyName

Please help this is driving me insane.
Georgi

The easiest way would be to add another criterion to the query. This
new criterion would be placed on the Company (or CompanyID, or
CompanyName) field; and it would be

=[Forms]![CallDialog]![cboCompanyName]

I don't know whether your combo box's bound column is an ID field or the
actual company name, since it could show the company name but store an
ID internally. That will affect exactly how you apply the criterion to
the query.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top