Results 1 to 5 of 5
  1. #1
    Join Date
    May 2002
    Location
    at the corner of flotsam & jetsam, just within the walls of reality
    Posts
    21

    Question 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.

    any assistance is appreciated in advance.

  2. #2
    Join Date
    Apr 2002
    Location
    Germany
    Posts
    228
    use the Updated event of the control and use it's value in your query

  3. #3
    Join Date
    May 2002
    Location
    at the corner of flotsam & jetsam, just within the walls of reality
    Posts
    21
    sorry, you lost me on that? when i click on the ellipsis in the update event (the 3 dots button), i get the options for building expressions and code modules. what do i do there?

  4. #4
    Join Date
    May 2002
    Location
    Bognor Regis ,UK
    Posts
    1

    Talking

    Hi Lostdreamer,

    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?

  5. #5
    Join Date
    Apr 2002
    Location
    Germany
    Posts
    228
    to lostdreamer:

    when you want to open a query your code would look something like that after cosing code:

    DoCmd.OpenQuery "MyQuery"

    in your query you would have something like:

    SELECT ...
    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.

    to gazzabob:

    on the OnUpdate event something similiar to this:
    Code:
    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
            exit sub
        end if
    
        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
        else
            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
        end if
    CalendarUpdateExit:
    on error resume next
        dbs.close
        set dbs = nothing
        exit sub
    CalendarUpdateError:
        'error handling code here
        goto CalendarUpdateExit
    end sub
    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

    Michael

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •