If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
class moduole errors - please help
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 |
#2
|
|||
|
|||
class moduole errors - please help
On Sat, 28 Apr 2007 22:50:01 -0700, accessfremont wrote:
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 /////////////////////////////////////////////////////////////////////////////////////////////// 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 |
Thread Tools | |
Display Modes | |
|
|