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

ocxCalendar Problems 1

Status
Not open for further replies.

mcongdon

Programmer
Mar 14, 2008
98
0
0
US
I would like the calendar to work as follows (in an unbound form in order to use date for queries):
1) Click empty combo box cboStartDate to bring up calendar
2) Calendar opens to current month
3) User can click on calendar to select date
4) The date selected in the calendar is entered in cboStartDate
5) The calendar hides again

I used this code in another form and it worked perfectly, I don't know what the difference is, but for some reason this time it never changes dates. No matter what date I select on the calendar, 3/5/2008 is entered in cboStartDate

Code:
Private Sub cboStartDate_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    ocxCalendar.Visible = True
    ocxCalendar.SetFocus
    If Not IsNull(cboStartDate) Then
        ocxCalendar.Value = cboStartDate.Value
    Else
        ocxCalendar.Value = Date
    End If
End Sub

Private Sub ocxCalendar_Click()
    cboStartDate.Value = ocxCalendar.Value
    cboStartDate.SetFocus
    ocxCalendar.Visible = False
End Sub

Thanks Guys!
 
Why using a combo instead of a TextBox ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
A combo box generally shows a value that is in its list, whereas a textbox will display what its told to display.

I've had similar difficulties with setting and retrieving dates from an activeX calendar when I copy and paste the calendar onto another form, and even if the form was imported.

I usually get around my calendar issues by deleting the calendar and using the Access toolbox to put a new activeX calendar on my form. The code can remain the same so long as the calendar is renamed to the correct name.
 
Hey guys,
thanks for the responses. Imhuman, I tried that when I first noticed it wasn't working. I rebuilt the entire form from scratch. It worked for one go around, then it's back to using one date consistently, no matter what I click on the calendar. I even renamed everything by appending a 1 on it and changed the code to match, just to make sure it wasn't confusing form controls. Still nothing. PHV, I just tried converting it to a textbox and that still has the same issue. I used a combo box in the first place so that an end user would see that they should click on it to drop down a date selector. The text box looks like it wants someone to manually enter dates.
 
Perfect- that calendar makes so much more sense than the one included with Access. Much more versatile for what I want to do as well.
The text box was a great tip too!
Thanks guys!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top