pick date from calendar for a date field

Jabez

New member
Local time
Today, 13:23
Joined
Apr 29, 2002
Messages
6
I am trying to do the following: insert a user-selected date into a date field on a form by clicking on a calendar.

I have done: created a command button next to the date field. This command button opens a form with a calendar (Calendar Control 10.0). I have put a command button underneath the calendar with the text "Insert selected date into date field".

So far so good... (please tell me if I'm on the right track). Here I get stuck. Obviously when the user clicks on this command button, the idea is for the selected date to jump into the date field, and the calendar must close.

The command button wizard gives me a few options:
- Record navigation
- Record operations
- Form operations
- Report operations
- Application
- Miscellaneous

What step do I choose here? By a process of elimination I choose Miscellaneous -> Run Macro. (Am I still on the right track??) Now the wizard wants to know which macro I want to run. I suppose I must write the macro... Please help!!

I have never done this before and don't know if I'm chasing my own tail. If there is a better way of doing this thing, please teach me. If I am on the right track, please help me over this hurdle.

Thanks a lot!
 
The date you select is contained in a field with its visible property set to "False." on the calendar. You have to store that value into your form.
 
...and how do I begin to do that? (Sorry, I am really stupid!)
 
Check the MSDN KnowledgeBase for "ActiveX". I have not otherwise been able to find explicit code for you.
 
I have now read through ~100 items after doing a search in this forum. I am only spiralling into an abyss of confusion.

I am not a programmer, so most of the computerspeak is greek to me. I don't even know what MSDN Knowledgebase means!

I wonder if someone in this forum would be willing to help me along in a simple and gentle way.

My logic tells me doing this thing is one of the very basic operations in a database. So, why is it so impossible to find out how to do it? Doesn't make sense to me. Maybe there is a simple sample database somewhere that I can look at?

All help will be much appreciated!!
 
If you are just trying to put a date into a textbox on a form other than the one that you have the calendar control on, use this code in the on click event of the command button that you have "Insert selected date..."

Forms!YourFormNameWithTheTextBox!YourTextBoxName.Value = MyCalendarControlName.Value

DoCmd.Close acForm, "YourFormNameWithTheCalendarControl", acSaveNo


I believe that should get you to where you want to go. Let me know if you run into problems and we'll troubleshoot. I have used the calendar control too, but it's been a while so I'm not totally sure, but I'm pretty sure that .Value will to the trick.

BL
hth
 
Bob!

I'm having a similar problem Jabez, I can fully sympathise!! I feel like I am going insane - or maybe I am just completely thick :-(

I have a similar set up, a main form with a date field, next to that a button which opens another form which I have inserted the ActiveXCtlCalendar on, this form has a close button. All working dandy so far...

Until I try to tell Access to put the value of the calendar into the date field on the first form. Tried various combinations of the following code:

This is set in the 'close calendar button' in 'on click':

Private Sub CloseCalendar_Click()

Forms!frmPlacingRequest![Date Received].Value = Me.ActiveXCtlCalendar.Value

DoCmd.Close acForm, "frmCalendar", acSaveNo

End Sub


I then get a "run time error 2448 You can't assign a value to this object".

Which is much in line with what you suggested, am I missing somit simple?
 
The Line

Forms!frmPlacingRequest![Date Received].Value = Me.ActiveXCtlCalendar.Value

is [Date Received] the name of the field or control? It should be the name of the control on the form, not the field value it stores. Also it is not good practice to have spaces in field names, controlnames, tablenames etc as it makes them more difficult to refer to. Instead, make the line read

Forms!frmPlacingRequest!txtDateReceived.Value = Me.ActiveXCtlCalendar.Value, where txtDateReceived is the name of the textbox storing the date
 
Fizzo,

It's amazin' how simple a problem becomes if you just go away and forget about it for a while!
biggrin.gif


[Date Received] was the name of the control on the the form, but I had changed the control name on the form and forgot to change the table
frown.gif
Hey, it was a buzi day yesterday!!

Thanks also for your comments on naming fields, controls, etc. I've noted these comments for future reference.

Cheers!

Sue
 
I have a good example for you, if you want it I can send it to you. That way you won't have to do the big runaround with all of this other feedback, that is probably overwhelming you.

If you need it, just reply a post with your email and I will send it to you.
 
tjs206,

Can you email a copy to greg.smith@setechusa.com?

Thanks
 

Users who are viewing this thread

Back
Top Bottom