|
-
Apr 12th, 2007, 09:05 PM
#1
Thread Starter
Member
Access - Calendar Control - popup event
I'm trying to use a calendar in Access 2003 to enter data in data fields.
I found a site that showed how to write the code so it will popup when you click on the date field and then disappear when you select the date from the calendar.
I got it working but I want to be able to access that same calendar for other date fields on the form.
So I used a variable call 'originator' to pass the originators name to the variable.
Only thing is...now it doesn't work. I get a type mismatch error and I don't know why. It's exactly the same as the example I found(obviously with my names substituted in).
Please help. (dob is the field I want the date to go into and Calendar6 is the name of the calendar I'm using.) Here's my code:
Option Compare Database
Option Explicit
Dim originator As ComboBox
Private Sub dob_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Set originator = dob
Calendar6.Visible = True
Calendar6.SetFocus
If Not IsNull(originator) Then
Calendar6.Value = originator.Value
Else
Calendar6.Value = Date
End If
End Sub
Private Sub Calendar6_Click()
originator.Value = Calendar6.Value
originator.SetFocus
Calendar6.Visible = False
Set originator = Nothing
End Sub
-
Apr 13th, 2007, 02:54 AM
#2
Re: Access - Calendar Control - popup event
isn't dob a textbox ---- originator is classed as a combobox?
shouldn't originator be classed as a control?
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
Apr 13th, 2007, 03:20 AM
#3
Thread Starter
Member
Re: Access - Calendar Control - popup event
so you think try putting
'dim originator as textbox'
or
'dim originator as control'
?
I'll try them when I get home from work.
-
Apr 13th, 2007, 04:40 AM
#4
Lively Member
Re: Access - Calendar Control - popup event
headsbout2burst
I have a similar feature in one of my access applics. I got it from a website somewhere i dont remember. It uses a module for poping-up the calendar. It works with the on_click event of the textbox or of a little button next to your date txtbox - as you choose to make it in fact.
It works abs fine. I can upload it all in a small sample db here if ever you cant resolve your current error.
Good luck
-
Apr 13th, 2007, 08:42 AM
#5
Re: Access - Calendar Control - popup event
Code:
dim originator as control
Then you can put either textbox of combobox - I assume you are setting the .text property (VB) or the .value property (vba).
Give it a go and see if it does anything.
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
Apr 13th, 2007, 12:52 PM
#6
Thread Starter
Member
Re: Access - Calendar Control - popup event
yes, dim originator as control works.
but now its not inputting the date you select from the calendar, just puts in todays date!! bizzarre...any ideas why?
here's my revised code:
Code:
Option Compare Database
Option Explicit
Dim originator As Control
Private Sub dob_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Set originator = dob
Calendar6.Visible = True
Calendar6.SetFocus
If Not IsNull(originator) Then
Calendar6.Value = originator.Value
Else
Calendar6.Value = Date
End If
End Sub
Private Sub Calendar6_Click()
originator.Value = Calendar6.Value
originator.SetFocus
Calendar6.Visible = False
Set originator = Nothing
End Sub
-
Apr 14th, 2007, 04:21 AM
#7
Thread Starter
Member
Re: Access - Calendar Control - popup event
I've done it. thanks for your help.
don't know what was wrong, I just deleted everything and started again. worked this time.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|