A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Database Design
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

class moduole errors - please help



 
 
Thread Tools Display Modes
  #1  
Old April 29th, 2007, 06:50 AM posted to microsoft.public.access.tablesdbdesign
accessfremont
external usenet poster
 
Posts: 4
Default 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  
Old May 1st, 2007, 12:57 PM posted to microsoft.public.access.tablesdbdesign
Scott McDaniel[_2_]
external usenet poster
 
Posts: 10
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 12:21 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.