DoCmd.OpenReport

ariel81

Registered User.
Local time
Today, 01:11
Joined
Dec 31, 2006
Messages
75
hi,

i have a code:
Code:
    Dim stDocName As String
    Dim f As Form
    
    Set f = Forms!frmFltQpi

    stDocName = "FLT Report"
    DoCmd.OpenReport stDocName, acPreview, , f.cboFltQpiYear

basically if the value in the f.cboFltQpiYear is 2006 it should print out the rows with "2006" in the table. however it print out not only 2006 but also all the other years in the table. how to select only for year 2006?
 
Change this:
Code:
    Dim stDocName As String
    Dim f As Form
    
    Set f = Forms!frmFltQpi

    stDocName = "FLT Report"
    DoCmd.OpenReport stDocName, acPreview, , f.cboFltQpiYear

to this (if your year is listed as text)
Code:
    Dim stDocName As String
    
    stDocName = "FLT Report"
    DoCmd.OpenReport stDocName, acPreview, , "[TypeTheFieldNameInYourReportThatIsTheYear]= '" & Me.cboFltQpiYear & "'"

Be sure to type in your actual field name (keeping the quotes and brackets) into the spot marked "TypeTheFieldNameInYourReportThatIsTheYear"
 
thank you...
however, my year is listed as number in the table
how shall the syntax be for "number" instead of text?
 
Same syntax, just remove the single quotes (').
 

Users who are viewing this thread

Back
Top Bottom