Help with Module (1 Viewer)

Bigmo2u

Registered User.
Local time
Yesterday, 23:18
Joined
Nov 29, 2005
Messages
200
I have attempted to create a module, 1st time trying. i have done a lot of searching but i guess the light has turned on as to what I am doing.

I want to check the date to see if it is a weekend and push the date to Monday. So here is the get and set (i used a book to help me along).

Code:
Private DateValidation As Date

Public Property Get dateCheck() As Date

dateCheck = DateValidation

End Property


Public Property Set dateCheck(ByVal sDate As Date)

sDate = WeekdayName(Weekday(Me.Claim_Received, vbUseSystemDayOfWeek), _
                     False, vbUseSystemDayOfWeek)

Select Case sDate
    Case Is = "Saturday"
        sDate = (sDate + 2)
    Case Is = "Sunday"
        sDate = (sDate + 1)
End Select

DateValidation = sDate

End Property

Would this be the Set/Get code on the form:

Code:
Set dateCheck = Me.ClaimReceived
Me.ClaimReceived = dateChecked

Not sure how to "SET" and "GET" the variable from the module.

Please don't bash me on naming conventions, I will fix that once the code is finalized.
 
Last edited:

DCrake

Remembered
Local time
Today, 05:18
Joined
Jun 8, 2005
Messages
8,632
Simple Software Solutions

To simplify what you are doing try this.

Create a function called TestDate

Code:
Public Function TestDate(AnyDate As Date) As Date

Dim D As Integer

Select Case Format(AnyDate,"mmm")
    Case "Sat" :D = 2
    Case "Sun" :D = 1
    Case Else :D = 0
End Select

TestDate = DateAdd("d",D,AnyDate)

End Function

Then in you form simply reference the function by calling it. Eg

Me.TxtDate = TestDate(DateToTest)

Or in a query use

NewDate:TestDate(DateToTest)

CodeMaster::cool:
 

Bigmo2u

Registered User.
Local time
Yesterday, 23:18
Joined
Nov 29, 2005
Messages
200
DCrake - Thank you so much. I knew I was making it harder than it had to be.

Select Case Format(AnyDate, "mmm")

shouldn't it be:

Select Case Format(AnyDate, "ddd") to get the day of the week?
 

DCrake

Remembered
Local time
Today, 05:18
Joined
Jun 8, 2005
Messages
8,632
Simple Software Solutions

Even the best can make simple errors:eek:
 

Bigmo2u

Registered User.
Local time
Yesterday, 23:18
Joined
Nov 29, 2005
Messages
200
DCrake - Like I said i am new to this and was just asking, not trying to point out a mistake.

Thanks for your help.
 

Users who are viewing this thread

Top Bottom