If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Calendar Object
Howard,
The strUser_Selected_Date should be assigned as a Global in the Calendar module. Your text box can still be bound to the date field in your table. It should update OK. You may need to change strUser_Selected_Date to a date by using; cdate(strUser_Selected_Date) Hope this helps. Steve. -----Original Message----- Steve, Where does the variable "strUser_Selected_Date" come from. ARe you assuming this is the name of my text box on my form which is calling the calendar form? Let me know. Thanks! -Howard -----Original Message----- Aha! Just put an Add Date command button to your calendar form and put the following code in the On_Click event; When this is clicked, it updates the date in your textbox. Private Sub Command1_Click() strUser_Selected_Date = ActiveXCtl0 DoCmd.Close acForm, "frmCalendar" End Sub -----Original Message----- Yes, I did do that part. The calendar does pop up as expected (in full screen mode, however, which is ugly), but when I click on a date on the calendar, nothing really happens. I need to manually close the calendar window, which puts in a zero date in the text box I have on my form. If this is not clear, let me know. Thanks again! -Howard -----Original Message----- Did you make an On_Click event for the textbox you want to populate with the date? You need to call the Function from this event..... Private Sub Text0_Click() Text0 = Get_Date End Sub Steve. -----Original Message----- Thanks Steve, Actually I figured out that I had to create a module and was about to email you back to let you know, when I received yours. Anyway, I don't think I have implemented it correctly. Nothing happens when I click a date on the calendar form, after it pops up. If I close the form, I just get a bogus date (I think a date respective of zero). I then tried to put the Command1_Click() function under the celendar form event for "click on form". It still doesn't select the date clicked or close the form. I think that function is the key to my issue. What do you suggest? Thanks! -Howard -----Original Message----- Howard, Create a new Module called mdlGlobal. Paste the code between '******** and End Function into the module. Ive found the line; Global dteSelected_Date As Date ' Stores the date Works better as a string, so change it to; Global strSelected_Date As String ' Stores the date If you require any more help, just ask. Steve. -----Original Message----- Hi Steve, One problem, being a newbie to the programing side of Access, it won't allow me to declare the global variables you specified within the Calendar form (or any form for that matter) as it state that global variables cannot be declared within an object. Where do I delare these? Plese let me know. I'm glad you'll be able to use this in your applications. Thanks! -Howard -----Original Message----- Howard, Slightly new approach (I've just had a quick at creating this) Still create the Calendar form. You will need a Function to Open the form and get the selected date. '***************************************** ********* * 'Calendar Form Global blnCalendar_Open As Boolean ' Set as True to keep the calendar form open. Global dteSelected_Date As Date ' Stores the date selected on the Calendar Form. '***************************************** ********* * Public Function Get_Date() As Date dteSelected_Date = 0 DoCmd.OpenForm "frmCalendar" Do Until blnCalendar_Open = False DoEvents Loop Get_Date = dteSelected_Date End Function The calendar Form should have the following Sub procedures; Private Sub Command1_Click() dteSelected_Date = ActiveXCtl0 DoCmd.Close acForm, "frmCalendar" End Sub Private Sub Form_Close() blnCalendar_Open = False End Sub Private Sub Form_Open(Cancel As Integer) blnCalendar_Open = True End Sub Then finally, in the On Click event for the text box, you need to call the Get_Date function; Private Sub Text0_Click() Text0 = Get_Date End Sub And that my friend, should do the trick! I've got a new feature for some of my database's now Cheers, Steve. -----Original Message----- Hi All, In many forms in several applications, I use date fields (text box) for the user to enter a date. I would like the user to be able to select the date from a pop-up window. Can I use the Calendar Control 9.0 (Active X Control) to do this? How would I implement it? Is this the best way to do this? Please let me know. Thanks! -Howard . . . . . . . . . |
#2
|
|||
|
|||
Calendar Object
Hi Steve,
Couldn't get it to work at all, so I did a little investigation on the net. I found another alorythm to try. The only thing I didn't like about it was that it directly referenced the date field on my form from within the calendar form which doesn't apply itself to re-use nicely. I used your approach by setting a global variable instead. This method does not require a command button. It uses the object_click as the event. The problem I have now is that it passes the date from the previous selection each time. ie. if I click on may 20, it passes 31dec99. If I click again and select may 4, it passes may 20. If I click again and select may 15, it passes may 4. etc, etc, etc. Please help! Thanks - Howard The code is as follows: "Date_Required" is my date field in my "Components" form "Calendar" is the calendar form "ActiveXCtl" is the calendar object on the calendar form "Selected_Date" is the global date field THIS IS THE FUNCTION IN MY FORM TRIGGERED BY CLICKING ON MY DATE FIELD .... Private Sub Date_Required_Click() ' Show ActiveXCtl and set its date. Dim stDocName As String Dim stLinkCriteria As String stDocName = "Calendar" DoCmd.OpenForm stDocName, , , stLinkCriteria Forms![Calendar]!ActiveXCtl.Visible = True Forms![Calendar]!ActiveXCtl.SetFocus ' Set to today if date_opened has no value. Date_Required.Value = Selected_Date ' Forms![Calendar]!ActiveXCtl.Value = IIf(IsNull (Date_Required), Date, Date_Required.Value) End Sub THIS IS THE FUNCTION TRIGGERED BY CLICKING ON THE CALENDAR OBJECT IN THE CALENDAR FORM Private Sub ActiveXCtl_Click() ' Set date_closed to the selected date and hide the ActiveXCtl. Selected_Date = Forms![Calendar]!ActiveXCtl.Value DoCmd.Close End Sub THIS IS MY GLOBAL DECLARATION Option Compare Database '************************************************* ******** 'Calendar Form Global Selected_Date As Date 'Stores the date selected on the Calendar Form '************************************************* ******** -----Original Message----- Howard, The strUser_Selected_Date should be assigned as a Global in the Calendar module. Your text box can still be bound to the date field in your table. It should update OK. You may need to change strUser_Selected_Date to a date by using; cdate(strUser_Selected_Date) Hope this helps. Steve. -----Original Message----- Steve, Where does the variable "strUser_Selected_Date" come from. ARe you assuming this is the name of my text box on my form which is calling the calendar form? Let me know. Thanks! -Howard -----Original Message----- Aha! Just put an Add Date command button to your calendar form and put the following code in the On_Click event; When this is clicked, it updates the date in your textbox. Private Sub Command1_Click() strUser_Selected_Date = ActiveXCtl0 DoCmd.Close acForm, "frmCalendar" End Sub -----Original Message----- Yes, I did do that part. The calendar does pop up as expected (in full screen mode, however, which is ugly), but when I click on a date on the calendar, nothing really happens. I need to manually close the calendar window, which puts in a zero date in the text box I have on my form. If this is not clear, let me know. Thanks again! -Howard -----Original Message----- Did you make an On_Click event for the textbox you want to populate with the date? You need to call the Function from this event..... Private Sub Text0_Click() Text0 = Get_Date End Sub Steve. -----Original Message----- Thanks Steve, Actually I figured out that I had to create a module and was about to email you back to let you know, when I received yours. Anyway, I don't think I have implemented it correctly. Nothing happens when I click a date on the calendar form, after it pops up. If I close the form, I just get a bogus date (I think a date respective of zero). I then tried to put the Command1_Click() function under the celendar form event for "click on form". It still doesn't select the date clicked or close the form. I think that function is the key to my issue. What do you suggest? Thanks! -Howard -----Original Message----- Howard, Create a new Module called mdlGlobal. Paste the code between '******** and End Function into the module. Ive found the line; Global dteSelected_Date As Date ' Stores the date Works better as a string, so change it to; Global strSelected_Date As String ' Stores the date If you require any more help, just ask. Steve. -----Original Message----- Hi Steve, One problem, being a newbie to the programing side of Access, it won't allow me to declare the global variables you specified within the Calendar form (or any form for that matter) as it state that global variables cannot be declared within an object. Where do I delare these? Plese let me know. I'm glad you'll be able to use this in your applications. Thanks! -Howard -----Original Message----- Howard, Slightly new approach (I've just had a quick at creating this) Still create the Calendar form. You will need a Function to Open the form and get the selected date. '**************************************** ********* * * 'Calendar Form Global blnCalendar_Open As Boolean ' Set as True to keep the calendar form open. Global dteSelected_Date As Date ' Stores the date selected on the Calendar Form. '**************************************** ********* * * Public Function Get_Date() As Date dteSelected_Date = 0 DoCmd.OpenForm "frmCalendar" Do Until blnCalendar_Open = False DoEvents Loop Get_Date = dteSelected_Date End Function The calendar Form should have the following Sub procedures; Private Sub Command1_Click() dteSelected_Date = ActiveXCtl0 DoCmd.Close acForm, "frmCalendar" End Sub Private Sub Form_Close() blnCalendar_Open = False End Sub Private Sub Form_Open(Cancel As Integer) blnCalendar_Open = True End Sub Then finally, in the On Click event for the text box, you need to call the Get_Date function; Private Sub Text0_Click() Text0 = Get_Date End Sub And that my friend, should do the trick! I've got a new feature for some of my database's now Cheers, Steve. -----Original Message----- Hi All, In many forms in several applications, I use date fields (text box) for the user to enter a date. I would like the user to be able to select the date from a pop-up window. Can I use the Calendar Control 9.0 (Active X Control) to do this? How would I implement it? Is this the best way to do this? Please let me know. Thanks! -Howard . . . . . . . . . . |
Thread Tools | |
Display Modes | |
|
|