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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with a calendar control 1

Status
Not open for further replies.

ramrags

IS-IT--Management
Aug 17, 2001
62
US
I have a small doctor’s office database and I want to add a scheduling program to the database using a calendar control. Never using this control before I’m not really sure how it works, but what I was thinking is that I want the control to be on a main form with a sub form attached to it opening to the date that has the focus, with the time increments as part of this sub form. Once again I never used this control before so I’m not sure how the calendar returns the date value, so if anyone has an idea on the best way to go about this I would really appreciate the help you can give. Thanks Tom
 
It is a pain in the patooties, but here ya go.

Add the control to the form, set visible = false in the Format Tab
rename it something better in the Other Tab
In the Event Tab choose event procedure for any event and click the build(...)
At the top of the VBA window use the drop down on the right and choose "AfterUpdate"
Add this code...
******
Private Sub purchCal_AfterUpdate()
Me.purchCal = Format(Me.purchCal, "mm/dd/yyyy")
Me.purchCal.SetFocus
Me.purchCal.Visible = False
End Sub
******
Create a button on the form to "open" the calendar, or on double click of an item, or whatever. Add this to the event
******
Private Sub purchCalBtn_Click()
If IsNull(Me.PurchaseDate) Then
Me.purchCal = Format(Date, "mm/dd/yyyy")
Me.purchCal.Visible = True
Else
Me.purchCal = Me.PurchaseDate
Me.purchCal.Visible = True
End If
End Sub
*******
Basically, if you have a date already in the field, the calendar will then open to that date. If it is empty it will open with Todays date set. After you click on a date in the calendar, it will update to the day clicked.

Keep in mind that the event is not listed in the Event Tab. Dont know why, but its not. Sometimes due to the after Update event, if it opens to today, you cant click on today, you must change the date to hide the calendar. Couple ways to do this...
Set the GotFocus event of the date box to hide the calendar,
Set the lostfocus event of the calendar to move focus elsewhere and hide.(me.text.setfocus,me.cal.visible = false)
This way is a pain to handle.
Or set the Click property of the Calendar to do the same as the after update, ive had to use both to stop errors from happening (Click and AfterUpdate).

Make sense?
 
I’m reposting this thread because I’m not sure if I asked the right question before, I’ve been away and hadn’t had time to work on this database I appreciate the response I received but it was not really what I was looking for. I want to make this schedule form with a calendar on it and keep track of appointments. I have a start on it; I have an unbound form with an active x calendar object on it called frmSCHEDULE. I have another form that makes my appointments called frmAPPOINTMENT. I have one more form bound to a query that returns my appointment data by the date I pick from frmSCHEDULE this is working o.k...
The problem that I’m having now is the way things look what I want is to have a form that shows all the times available in 15 min intervals with the appointments for the corresponding time on the same line. Right now I get the results of my query so when you look at it you can not tell what time are left. I hope that this makes sense. Some other background I have a table called tblTIME that just have a ID field and a time field that keep time in the 15min intervals I use this on my frmAPPOINTMENT as a combo box to select a time. So if you understand this question and can offer help I would really appreciate it thanks,, Tom
 
ramrags,

I am also trying to use the calendar control to extract data from a table basedon a selected date. I am having some problems getting it to work and I was wondering if you could send me an exapmle of the code you used to get yours to work.

Thanks
greg
 
What I did was make a table that keeps my data for my appointments this keeps stuff like patient data, and date of appointment, which is the field that I want to query the info by. Then I created a unbound form and added the calendar control to it and I also added a text box just to keep track of the date I click on. I also created another form to display the data that I want. I also made a query for the info I wanted and in the Criteria line I added [Forms]![frmSCHEDULE]![txtDATE_NOW]. To the load event on the calendar form I used the code.
Private Sub Form_Load()
Dim DATE_NOW As String
Dim Criteria As String
Me!conCal.Value = Date ‘used to open the calendar to today’s date
Me!conCal.SetFocus ‘conCal is the name I gave the calendar control
DATE_NOW = Me!conCal.Value
Criteria = DATE_NOW
txtDATE_NOW = DATE_NOW
DoCmd.OpenForm "frmTIME_SUB" ‘this open the form to display the data

End Sub

Then to the click event on the control I added the code.
Private Sub conCal_Click()
Dim answer As String
Dim result As String
Dim Criteria As String
answer = Me!conCal.Value
txtDATE_NOW = answer
DoCmd.Save , "frmSCHEDULE"
DoCmd.close , "frmTIME_SUB", acSaveYes
txtDATE_NOW = answer
DoCmd.OpenForm "frmTIME_SUB"
Criteria = answer

DoCmd.OpenForm "frmTIME_SUB", , , Criteria
End Sub
This updates the sub form and gives me the info by the data I click on I’m not sure if this is the best way to do it but it does work for me. It’s just what I want it to do but I cant get it to display the way I want but I think what I have to do is write a big case statement. I hope this helps in your program. Tom
 
Ramrags,

Thanks for the code. my problem is that I defined my application as a project and it appears as if some things don't work the same way.
I was able to implementit succesfully.
Greg
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top