Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calendar Control 1

Status
Not open for further replies.

cldh00

MIS
May 10, 2002
27
US
I have a form that I would like to use a calendar control for. This form will be used to track surgeries. I would like to set up a button on a form and when you click it, have a calendar pop up. When you click a date, this will be the start date, and then the calendar will disappear and another calendar will pop up. When you click another date, this will be the end date and then the calendar will disappear, and a query will pop up on the screen listing all surgeries scheduled from the start date to the end date. Can someone please point me in the right direction on how to accomplish this? Thanks!

Chad
 
Hi
A good place to start is the FAQ for this forum.
 
Also see thread181-851861

and consider option of using DateTime Picker control (search these fora).
 
Add the ocxCalendar Control 11.0 object to your form, once for the text box to hold the start date and another for the text box holding your end date. Bind each ocxCal control to the appropriate textbox.

I use code such as:
===================================
Private Sub ocxCalDR_GotFocus()

'maintains existing date if one already exists
If txtDateRecv.Value <> Date Then
ocxCalDR.Value = txtDateRecv.Value
Else
ocxCalDR.Value = Date
End If

End Sub
======================================
and
Private Sub ocxCalDR_KeyPress(KeyAscii As Integer)
'write the date selected to the text box and move to next control
txtDateRecv.Value = ocxCalDR.Value
cboBranchID.SetFocus

ocxCalDR.Visible = False

End Sub
=====================================
and
Private Sub ocxCalDR_Click()
'moves focus to the next control and hides the calendar after update
cboBranchID.SetFocus
ocxCalDR.Visible = False

End Sub
================================
and
Private Sub txtDateRecv_GotFocus()
'shows the calendar when the bound text box has focus
ocxCalDR.Visible = True
ocxCalDR.SetFocus
End Sub
=============================
and I've got the same code in the MouseDown event of the this text box.

You'll probably want to use more code to set the calendar's visible property to false when other controls getfocus.

Hope this helps.
 
I have gotten a lot farther thanks to the previous posts. Currently, I have the form made and click a button which brings up a calendar and click on a date, and this date goes in a "BeginDate" text box and the calendar disappears. I also have another button which also brings up a calendar and you just click on a date, and this date goes in the "EndDate" text box and the calendar disappears again. So, I have the correct "BeginDate" and the correct "EndDate". I also have a button below these 2 text boxes that is my "Get Schedule" button. I don't have any code for this button yet. When the user clicks this button, I need it to look at a table in the database, and bring up some of the fields that are listed, such as Dates of Surgery (that are between the BeginDate and EndDate, Patient name, the Surgeon and the procedure performed. Could someone guide me in the right direction on how to code this button? Thanks!
 
You need to have a query first.
Then in the criteria of the date field you have to put
Code:
Between [Forms]![YourFormName]![txtBeginDate] And[Forms]![YourFormName]![txtEndDate]

Remember to change the textbox name and formname to the actual names.

Then add a command button through wizard to open the query that you just created.

also you can create a report with this query and open it by clicking the command button

________________________________________________________
Zameer Abdulla
Help to find Missing people
My father was a realistic father; not a vending machine dispense everything I demanded for!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top