at the corner of flotsam & jetsam, just within the walls of reality
Unanswered: calendar control
hello, i have a question regarding the calendar control. (i have searched for calendar control in the topics, but none address my issue, which is a more basic question.)
i know how to add a calendar control to a form, but i don't understand how to get it to do what i want. in my db, i schedule appointments for services. i have a form with two subforms (all corresponding to their respective tables), and i'd like to add this calendar control to this form, such that, when i click on a date (e.g., 5/7/02), a window pops open that shows all appointments for that date. that window could just be a query or parameter query.
I too am trying to puzzle this one out. I think what 'Apel' is trying to say is you first need to create a query then create some code in the OnUpdate property of the calendar's control that will interact with the database query - sounds simple if you know how.
I am building a calendar/Diary. I have created a Diary page and registered the Calendar control. I want to know if any one out there can actually help out with the coding.
What I need is the code that sends the date value from the control to the database table. Once there, the code needs to check if the date value exists. If it does, then the value will diplay that record, or day in this case, if not to create a new record with that date value as the key field with no duplicates.
Are there any VBA Programmers out there that can help us novices?
when you want to open a query your code would look something like that after cosing code:
in your query you would have something like:
WHERE Date = Forms!Myform!MyCalendarControl
or if you prefer the query wizard
enter "Forms!Myform!MyCalendarControl" (without the quotes) in the criteria for the date field.
on the OnUpdate event something similiar to this:
Private Sub MyCalendarControl_Updated(Code As Integer)
on error goto CalendarUpdateError
dim dbs as database
set dbs = currentdb()
if Code <> acOLEChanged then
'only run when the data of the control has changed
if isnull(dlookup( _
"MyDate", "MyTable", _
"MyDate = #" & Me!MyCalendarControl & "#")) then
'look up the date in the table,
'if none matching is found dlookup returns null
'insert code to display records here
dbs.execute = _
"INSERT INTO MyTable (MyDate) VALUES (#" & _
Me!MyCalendarControl & "#);", dbfailonerror
'the execute method directly executes the given sql string supplied
'the dbfailonerror parameter ensures that an error is raised when
'the query wasn't executed completely successfully because of
'duplicate keys, locking or similiar
on error resume next
set dbs = nothing
'error handling code here
to you both
Those are just code snippets trying to give you an idea how to realise your tasks. I don't know precisiely what you are trying to do so I can't be much more specific. Hope this helps a bit