[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Calendar Control 9.0

Posted on 2007-07-26
14
Medium Priority
?
944 Views
Last Modified: 2012-05-05
This should be easy but for some reason I can't get it to work.  I have tried about four solutions that I found on ee and none of them worked for me. Maybe it is due to older versions, I dunno.

I have:

1 form: frmPeriodicReport_Custom
2 unbound textboxes: txtStartDate, txtEndDate
1 calendar control: ctlCalendar

What works so far:
When a user enters either of these fields the calendar control appears to the right of the textbox.
When the user exits the field, the calendar control is hidden

What doesn't work:
i need the value of the field to equal the value of the calendar control when the user clicks on a date in the calendar control. i would like to do this with ONE calendar control, so I will neeed to pass the fieldname.

I can't get the events for the calendar to run - I don't know why. I added a messagebox line in the event and it never fires. This is the code that I have so far:

Private Sub ctlCalendar_Click()
    MsgBox Me.ctlCalendar.Value
    Me.txtStartDate = Me.ctlCalendar.Value
End Sub

Private Sub Form_Load()
    Me.ctlCalendar.Visible = False
End Sub


Private Sub txtEndDate_Enter()
    With Me.ctlCalendar
        .Left = Me.txtEndDate.Left + Me.txtEndDate.Width + 200
        .Top = Me.txtEndDate.Top
        .Visible = True
    End With
End Sub

Private Sub txtEndDate_Exit(Cancel As Integer)
    Me.ctlCalendar.Visible = False
End Sub

Private Sub txtStartDate_Enter()
    With Me.ctlCalendar
        .Left = Me.txtStartDate.Left + Me.txtStartDate.Width + 200
        .Top = Me.txtStartDate.Top
        .Visible = True
    End With
End Sub

Private Sub txtStartDate_Exit(Cancel As Integer)
    Me.ctlCalendar.Visible = False
End Sub
0
Comment
Question by:adraughn
  • 5
  • 4
  • 3
  • +1
14 Comments
 
LVL 6

Expert Comment

by:twintai
ID: 19575746
As far as I know, you need the developer version of Access to get the calendar to work fully. I very well may be wrong that's the experience I remember having with it.
0
 
LVL 75
ID: 19575754
oh good ... another easy Q from Adria :-)

btw <totally mia you know who>

Image image image ....

mx
0
 
LVL 75
ID: 19575771
Possibly helpful ?

http://msdn2.microsoft.com/en-us/library/aa139958(office.10).aspx

http://office.microsoft.com/en-us/access/HA010546621033.aspx

TT ... doesn't seem you would need the Dev version ... that control is a standard Ax control in MsCtrls, no ?

mx
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 19576047
0
 
LVL 6

Expert Comment

by:twintai
ID: 19576164
DbMX - I think I may be wrong.....

adraughn - I think the problem may be the fact that your controls are unbound. I was trying to create a form with unbound controls recently and most of the Events did not trigger. My next step was to try having the fields bound to a table and see what happens.

So, why don't you create a temporary table to match the field names to the form controls. Then bound the form controls to table. I haven't tried this my self but my guess it that it will make a difference.
0
 
LVL 13

Author Comment

by:adraughn
ID: 19576431
<you need the developer version of Access to get the calendar to work fully.>
are you sure? why would they give you access to the active x, it's properties and events and not the ability to do anything with it?

<oh good ... another easy Q from Adria :-)>
stop whining mx :)

<btw <totally mia you know who>>
maybe the pic was fake and she is really a gay man with a bunch of kids on the side. Wait! I just described MIke! LOL

<Image image image ....>
Imagine, Imagine, Imagine.... - I know, hold your horses.

<Possibly helpful ?>
i'm checking it out now

cap: i want to use the MS control. i have a third party download as well but i need to learn how to get this one to work.

<My next step was to try having the fields bound to a table and see what happens.>
i would like to avoid binding the textboxes, if at all possible, since they are only going to be passed to my report - I don't need to save them or do anything else with them. I know I can build a temp table, but I consider this my last resort. There haws to be a way to do this without using a data source.

-a



0
 
LVL 13

Author Comment

by:adraughn
ID: 19576484
<Possibly helpful ?>
1. Tells me to use a table to hold the date
2. Also tells me to use Control Source

I'm starting to see a pattern here. Are we saying that you can't use the Calendar Control on an unbound form?

adria
0
 
LVL 75
ID: 19576516
"I know, hold your horses."
How about my cats instead.

Sorry ... I have not used the M$ Cal control ... as I mentioned before, I would use the DBI-Tech control if I need a serious control ...

mx
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 19576519

<i want to use the MS control>
that is a calendar control in the sample db.

and the form is unbound....
0
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 2000 total points
ID: 19576721
Here is something I found ... low cost (free) ... and looks kind of cool ... you might take a look at this:

http://www.fontstuff.com/access/acctut09.htm

I had seen this before ... but kind of forgot about it ...

mx
0
 
LVL 13

Author Comment

by:adraughn
ID: 19576798
thanks cap - but i'm not allowed to download anything to this machine.
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 19576836
upload a zip copy of your db at www.ee-stuff.com
0
 
LVL 13

Author Comment

by:adraughn
ID: 19576837
<you might take a look at this:>
works perfect mx! thanks!

-a
0
 
LVL 13

Author Comment

by:adraughn
ID: 19576984
In case someone needs it, this is the code I wrote from using the tutorial that mx sent me. I did choose to put the calendar code in a sub and call it since I will be calling it from multiple fields on my form.

Option Compare Database
Dim cboOriginator As ComboBox

Private Sub cboStartDate_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Set cboOriginator = cboStartDate
    Call PassDateFromCalendar
End Sub

Private Sub ctlCalendar_Click()
    cboOriginator.Value = ctlCalendar.Value
    cboOriginator.SetFocus
    ctlCalendar.Visible = False
End Sub

Private Sub Form_Load()
    Me.ctlCalendar.Visible = False
End Sub

Private Sub cboEndDate_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Set cboOriginator = cboEndDate
    Call PassDateFromCalendar
End Sub

Sub PassDateFromCalendar()
    Me.ctlCalendar.Left = cboOriginator.Left + cboOriginator.Width + 200
    Me.ctlCalendar.Top = cboOriginator.Top
    Me.ctlCalendar.Visible = True
    Me.ctlCalendar.SetFocus
   
    If Not IsNull(cboOriginator) Then
        Me.ctlCalendar.Value = cboOriginator.Value
    Else
        Me.ctlCalendar.Value = Date
    End If
End Sub
0

Featured Post

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
In a use case, a user needs to close an opened report by simply pressing the Escape (Esc) key. This can be done by adding macro code in Report_KeyPress or Report_KeyDown event.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Suggested Courses
Course of the Month19 days, 11 hours left to enroll

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question