report based on the selection of my 2 combo boxes

romio

Registered User.
Local time
Yesterday, 16:10
Joined
Apr 20, 2005
Messages
68
I need a button that will open a report based on the selection of my 2 combo boxes on my form:

Code:
find = "select count(*) from Records where Month = '" & commonth & "'" & "and Year = '" & comyear & "'"

How can I open my report based on this query.

Thanks.
 
Base the report on a query. In the query set the criteria for the appropriate columns to:

=Forms!formname!controlname

where formnane is the name of your form and controlname the named of the combo where the value to filter is selected
 
thats not gone help, on both combo boxes(month and year) the user will first have to chose from that form the month and year then the report will be based on that selection.... i dont want the user to access any queries
 
The user doesn't access any queries. They input the parameters and press a button and the report runs. I do this as SOP for any reports that involve parameters. its the easiest way to go.
 
Got working thank

sth is not going on right here:
Code:
If (Forms![Selectmonth]![commonth] <> "") Or (Forms![Selectmonth]![comyear] <> "") Then
DoCmd.OpenReport "RepRecords", acViewPreview
Else
MsgBox "Error, Please Enter A Month and A Year"
End If
my conditions request that both commonth and comyear not to be = to "", even though i leave one of them emtpy the report loads but with no data....!!! what am i doing wrong here.
 
romio said:
Got working thank

sth is not going on right here:
Code:
If (Forms![Selectmonth]![commonth] <> "") Or (Forms![Selectmonth]![comyear] <> "") Then
DoCmd.OpenReport "RepRecords", acViewPreview
Else
MsgBox "Error, Please Enter A Month and A Year"
End If
my conditions request that both commonth and comyear not to be = to "", even though i leave one of them emtpy the report loads but with no data....!!! what am i doing wrong here.

There is a difference between a null and a zero length string. Unless you have a default setting for your controls, an unselected combo is null not zero length. Since you are using Combos then zero length is not going to occur. So you want your code to be:

IF Not Isnull(Me!commonth) OR Not Isnull(Me!comyear) Then
 
mm, still not working, if leave both null then the error msg will popup, if only one it null then the msg wont popup!!.
Code:
If Not IsNull(Me!commonth) Or Not IsNull(Me!comyear) Then
DoCmd.OpenReport "RepRecords", acViewPreview
commonth = ""
comyear = ""
commonth.SetFocus
Else
MsgBox "Error, Please Enter A Month and A Year"
End If

but this way it did work:
Code:
If Not (IsNull(Me!commonth) Or IsNull(Me!comyear)) Then
DoCmd.OpenReport "RepRecords", acViewPreview
commonth = Null
comyear = Null
commonth.SetFocus
Else
MsgBox "Error, Please Enter A Month and A Year"
End If

Thanks ScottGem :)
 
Last edited:
Try it this way:

Code:
If IsNull(Me!commonth) Then
     MsgBox "You need to select a month!", vbOKOnly
     Me!commonth.SetFocus
Else
     If IsNull(Me!comyear) Then
          MsgBox "You need to select a year!", vbOKOnly
          Me!comyear.SetFocus
     Else
          DoCmd.OpenReport "RepRecords", acViewPreview
     End If
End If
 
ScottGem I think you didnt read my last post well :) hehe, its ok i got fixed. ;), I do appreciate your support a lot, thanks again.
 
I didn't read it correctly. Glad you got it working.
 

Users who are viewing this thread

Back
Top Bottom