469,963 Members | 1,853 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,963 developers. It's quick & easy.

Passing dates from combo boxes populated by Calendar Control 10.0

Hi All,

I'm in the process of creating a database that allows users to enter details into a form which includes a date range as start and end dates.

I have used the inbuilt Calendar Control 10.0 control to allow users to select the date. It is linked to two combo boxes [cmbStartDate] and [cmbEndDate] using the following code (this code is repeated for each combo box):

Expand|Select|Wrap|Line Numbers
  1.  Private Sub cmbStartDate_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  2.  
  3. Set cmbOriginator = cmbStartDate
  4.  
  5. ocxCalendar.Visible = True
  6. ocxCalendar.SetFocus
  7.  
  8.     If Not IsNull(cmbStartDate) Then
  9.  
  10.        ocxCalendar.Value = cmbStartDate.Value
  11.  
  12.     Else
  13.  
  14.        ocxCalendar.Value = Date
  15.  
  16.     End If
  17.  
  18. End Sub 
And..

[code] Private Sub ocxCalendar_Click()
''Update the ComboBox with the value entered into the ComboBox
''Put the value back into the relevant ComboBox
cmbOriginator.Value = ocxCalendar.Value

''Hide the calendar
cmbOriginator.SetFocus
ocxCalendar.Visible = False

''Clear the variable
Set cmbOriginator = Nothing

End Sub [\CODE]

This all seems to work fine- however, when I try to write the selected dates to a table or use them in a query they are not recognised (the form obviously needs to be open whilst the query runs), but if I manually type dates into these combo boxes these dates are picked up fine.

This is beginning to drive me mad so any help would be greatly appreciated.

Mark
Aug 23 '07 #1
2 2404
Hello All,

I've just re-read my post and I've missed out a vital piece of information: When the user has selected the relevant dates from the calendar control I am attempting to write the information to a table using an append query with [FORMS]![frmUpdate]![FieldName] syntax.

This works for all manually typed information from other fields on the form-but not for the VB-inserted dates from the control.

Does anyone know why?

Thank you
Aug 24 '07 #2
MMcCarthy
14,534 Expert Mod 8TB
You need to pass the date values either to bound textboxes or to Public variables which will hold the values so they are available later.
Sep 1 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

14 posts views Thread by Gary Shell | last post: by
2 posts views Thread by saloom | last post: by
7 posts views Thread by evilcowstare via AccessMonster.com | last post: by
3 posts views Thread by Mike P | last post: by
1 post views Thread by rainxy | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.