Active x calendar control (Mile)

CJBIRKIN

Drink!
Local time
Today, 14:47
Joined
May 10, 2002
Messages
255
Hi Mile/ anybody


I'm using the Active-X calendar control that Mile posted on a number of occasions.

I was wondering if it is possible to limit the days available for selection.

Basically i need a start and end date and i don't want the users to be able to select a start date that's after the end date or vice versa.

I've tried using the before update event of the text boxes to check the date is valid. I've also tried the validation option in the properties but neither of these seem to get triggered.

I'd like to avoid the form beforeupdate event if possible as that seems a bit "after the fact" i.e the users will have entered other information that may have dependancy on these dates.


Cheers

Chris
 
It might be possible programmatically by using a few things such as the OpenArgs of the calendar form wherby you send through a few values split by a delimiter (such as calling form, whether it's the start or end date being requested, and a date to not allow the user to go over or under depending upon it being the start or end date.

Or, you could make your database seem smarter by correcting the user if they gate the dates the wrong way round.

The MouseMove event of your form's Detail might work:

i.e.


Code:
Private Sub Detail_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Me.txtStartDate > Me.txtEndDate Then
        Dim d As Date
        d = Me.txtStartDate
        Me.txtStartDate = Me.txtEndDate
        Me.txtEndDate = d
    End If
End Sub
 
Hi Mile


The openargs is exactly the type of thing i want but how do you actually use that in conjunction with the activex control?

I've only used it to pass a SQL string to the opening form, for say a recordsource.

Sorry being thick here,




PHP:
Private Sub ctlCalendar_click()

    SetAndClose
    
End Sub

to


PHP:
Private Sub ctlCalendar_click()

if me.openargs ... what ever start and finish parameter  </> than ctlCalendar.Value then

Msgbox ("Blah blah")
else

    SetAndClose
end if   
End Sub


What do reckon?

Cheers

Chris
 
I'm a little stumped on this one - I've got three thngs passed to the calendar form as OpenArgs and then I've split them down again into the differing components.

It's just getting the SetAndClose part to work.


Will get back if I get it working...
 
Hi Mile


No worries i've done it.
PHP:
ShowCalendar(ByRef TxtDate As TextBox, ByRef Datetype As String)

As you can see i've added another variable DateType which is either A+date or D+date e.g A01/08/2003 or D01/08/2003




I've then used get and set functions to store this value (i'll try open args later as i was having a bit of a difficulty)



Then

PHP:
Private Sub ctlCalendar_click()
Dim Ddate As Date
Dim OArgsStr As String
'On Error Resume Next
 
OArgsStr = GetOpenArgStr


' if this is the first selection of the active date then there will be no deactivate date
' this means you can proceed as normal
If Left(OArgsStr, 1) = "A" And Len(OArgsStr) = 1 Then
SetAndClose
Exit Sub
End If

etc


That seems to work fine.


Thanks for your help

Chris
 

Users who are viewing this thread

Back
Top Bottom