class moduole errors - please help

G

Guest

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
 
S

Scott McDaniel

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.

I don't see where you've opened a New instance of clsReportFormat in the referenced code. In order to use your class
module, you'd have to do this:

Dim clsMyClass as clsReportFormat

Set clsMyClass = New clsReportFormat

Then you'd be able to use clsMyClass. Of course, you may have set this elsewhere in your code, but it's not showing
here.
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
////////////////////////////////////////////////////////////////////////////////////////////
if you've not Dimmed and Set your clsreportformat object, then the code will fail on the line below
///////////////////////////////////////////////////////////////////////////////////////////////
 

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