Thread: Calender Object
03-21-04, 09:34 #1Registered User
- Join Date
- Feb 2004
Unanswered: Calender Object
I have this new dbase I'm working for an optician's office. Like a previous dbase I was working on, I used the ActiveX Control Date Picker. I wanted to use it again, but I don't have it on my ActiveX Control Pad (working with Access 2000 but on ME platform) and I tried downloading and registering the OSX file but it still doesn't work. I have decided to use the Calender instead (Also heard this causes less complications).
There is a report in the Optician's dbase that shows the scheduled appointments for the current date. I have a commad button on the main swtichboard that opens a dialog box. On this dialog box, the user can double check the date on the calender. When the user clicks on "Go", the report for current appointments will show up. I have the following code in the Form Load Event:
Private Sub Form_Load()
'set it to default to today.
'this has to be done in the form_load event, can't be done in form_open as control is read only by then!!
Me.dtPickDate = Now()
And the following code in the Go command button:
'OPENS THE CALENDER POP-UP BOX FOR 'TODAY'S APPOINTMENTS'
Private Sub cmdGo_Click()
strWhere = "[DateOfAppointment]=#" & Format(Me.dtPickDate, "yyyy-mm-dd") & "#"
On Error Resume Next
'OPENS THE REPORT FOR TODAY'S APPOINTMENTS
DoCmd.OpenReport "rptCurrentAppointments", acViewPreview, , strWhere ', acWindowNormal
I edited it from the last dbase I did with the datepicker, it doesn't seem to be working. Any ideas how to fix this problem?
bajan_elf"The extreme always make an impression." - Jeff Hardy
03-21-04, 11:32 #2Cavalier King Charles
- Join Date
- Dec 2002
- Préverenges, Switzerland
well now: i have a solution to a slightly different problem, but you could probably adapt it to suit.
i don't like zillions of calendar controls all over the place so i use a single popup/modal date-select form holding a calendar control (plus a couple of other buttons that you can work out from the code below).
the "trick" if it is one, is to pass the object name of the destination textbox to the popup form. (typically i call this from _click in a textbox that is supposed to have a date in it)
Option Compare Database Option Explicit 'FORM popUserDate ' utility form to gather a user-entered date and insert it in the calling form 'USAGE ' calling form MUST use the following syntax: ' Dim TargetTextBox As TextBox 'prepare textbox object ' Set TargetTextBox = Me.NameOfTheTargetTextBox 'set the target textbox ' DoCmd.OpenForm "popUserDate" 'open the form ' Forms!popUserDate.popUserDateSetup TargetTextBox, "Caption", DefaultDate 'call the setup routine ' caller is responsible for a valid call. popUserDate atttempts to handle bad DefaultDates 'ACTION ' on error Me.NameOfTheTargetTextBox is unchanged else Me.NameOfTheTargetTextBox = user selected date 'DEPENDENCIES ' calling form MUST remain open until popUserDate is closed. popUserDate is popup/modal so this is ' the default behaviour, but code in this form must not be modified to close the caller Dim PUDtarget As TextBox 'the TargetTextBox in the calling form Dim initDate As Date 'this is the PUBLIC callable routine Public Sub popUserDateSetup(theTarget As TextBox, theCaption As String, theDefault As Date) Set PUDtarget = theTarget 'keep a local copy of the target textbox object Me.Caption = theCaption 'set the form caption If isDate(theDefault) Then initDate = theDefault 'save the initial value for a potential user-reset Else initDate = Now() 'if incoming date is bad, use today's date End If theCal = initDate 'set the calendar to the initial value End Sub Private Sub butCancel_Click() 'cancel: caller textbox is NOT changed DoCmd.Close acForm, "popUserDate" End Sub Private Sub butClear_Click() 'null the source date PUDtarget = "" DoCmd.Close acForm, "popUserDate" End Sub Private Sub butOK_Click() 'OK: update caller texbox and close popUserDate PUDtarget = theCal DoCmd.Close acForm, "popUserDate" End Sub Private Sub butReset_Click() 'reset to the date originally in the caller textbox theCal = initDate End Sub Private Sub butToday_Click() 'set today's date theCal = Now() End Sub
izycurrently using SS 2008R2