A
accessfremont
I am trying to use a function in the query which runs report based on dates
selected by user. I created class module called clsreportformat.
I made a function in another module which is called in a query. However I
keep getting the class module name highlighted in the function in a error
called variable not defined/ object error Can please someone tell me what is
wrong.
1. Event procedure when u click a compliments report button the form.
fldstartdate is name for startdate text box and fldenddate is name for end
date text box
Private Sub Compliment_Click()
If Nz(Me!fldstartdate, 0) = 0 And Nz(Me!fldenddate, 0) = 0 Then
MsgBox "Please enter a start date and or end date", vbInformation
Exit Sub
End If
If Not Nz(Me!fldstartdate, 0) = 0 And Not Nz(Me!fldenddate, 0) = 0 Then
clsreportformat.startdate = Me!fldstartdate
clsreportformat.enddate = Me!fldenddate
ElseIf Not Nz(Me!fldstartdate, 0) = 0 Then
clsreportformat.startdate = Me!fldstartdate
clsreportformat.enddate = Me!fldenddate
Else
clsreportformat.startdate = Me!fldenddate
clsreportformat.enddate = Me!fldenddate
End If
DoCmd.OpenReport "Compliment Query", acPreview
End Sub
2. Class module name :clsreportformat
Option Compare Database
Option Explicit
Dim dtestart As Date, dteend As Date
Property Let startdate(dtedate As Date)
dtestart = dtedate
End Property
Property Get startdate() As Date
startdate = dtestart
End Property
Property Let enddate(dtedate As Date)
dteend = dtedate
End Property
Property Get enddate() As Date
enddate = dteend
End Property
3. A Module named date
option Compare Database
Function fncgetstartdate() As Date
fncgetstartdate = Nz(clsreportformat.startdate, 0)
End Function
Function fncgetenddate() As Date
fncgetenddate = Nz(clsreportformat.enddate, 0)
End Function
selected by user. I created class module called clsreportformat.
I made a function in another module which is called in a query. However I
keep getting the class module name highlighted in the function in a error
called variable not defined/ object error Can please someone tell me what is
wrong.
1. Event procedure when u click a compliments report button the form.
fldstartdate is name for startdate text box and fldenddate is name for end
date text box
Private Sub Compliment_Click()
If Nz(Me!fldstartdate, 0) = 0 And Nz(Me!fldenddate, 0) = 0 Then
MsgBox "Please enter a start date and or end date", vbInformation
Exit Sub
End If
If Not Nz(Me!fldstartdate, 0) = 0 And Not Nz(Me!fldenddate, 0) = 0 Then
clsreportformat.startdate = Me!fldstartdate
clsreportformat.enddate = Me!fldenddate
ElseIf Not Nz(Me!fldstartdate, 0) = 0 Then
clsreportformat.startdate = Me!fldstartdate
clsreportformat.enddate = Me!fldenddate
Else
clsreportformat.startdate = Me!fldenddate
clsreportformat.enddate = Me!fldenddate
End If
DoCmd.OpenReport "Compliment Query", acPreview
End Sub
2. Class module name :clsreportformat
Option Compare Database
Option Explicit
Dim dtestart As Date, dteend As Date
Property Let startdate(dtedate As Date)
dtestart = dtedate
End Property
Property Get startdate() As Date
startdate = dtestart
End Property
Property Let enddate(dtedate As Date)
dteend = dtedate
End Property
Property Get enddate() As Date
enddate = dteend
End Property
3. A Module named date
option Compare Database
Function fncgetstartdate() As Date
fncgetstartdate = Nz(clsreportformat.startdate, 0)
End Function
Function fncgetenddate() As Date
fncgetenddate = Nz(clsreportformat.enddate, 0)
End Function