UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Date button on Calendar ActiveX    
 
   
Grafixx01
post Aug 15 2006, 11:05 AM
Post #1

UtterAccess Veteran
Posts: 450
From: Texas



Here's the situation:

I have a form, frmCalendar (the code for the entire thing is below), and it has a command button, cmdInsert_Date. This command button has to insert a date, when selected, on a parent form, frmTaskLog, in multiple text boxes. The only thing is this. This command must update a selected text box ONLY.

An example:

I have 'date to ceo', 'date from ceo' ; next to both of these text boxes there is a command button which opens the frmCalendar. When you select the certain date, then click the 'insert date' command button, the date must be inserted into the desired field, the one which you originally clicked the 'insert date' next to the 'date from/to ceo'.

Does anyone follow me? Or did I confuse everyone?

This is the code for the frmCalendar:

Option Compare Database
Option Explicit 'changed
Private strParentForm, strtextBox 'changed
Private Sub cmd_Insert_Date_Click()

Me.Visible = False 'changed
Forms(strParentForm).Controls(strtextBox).SetFocus 'changed
Forms(strParentForm).Controls(strtextBox).Text = CDate(frmCalendar.Value) 'changed
DoCmd.Close acForm, Me.Name, acSaveNo 'changed

End Sub

Private Sub cmdExtCal_Click()
On Error GoTo Err_cmdExtCal_Click


DoCmd.Close acForm, Me.Name, acSaveNo 'changed (added acForm, Me.Name, acSaveNo


Exit_cmdExtCal_Click:
Exit Sub

Err_cmdExtCal_Click:
MsgBox Err.Description
Resume Exit_cmdExtCal_Click

End Sub
Private Sub Command2_Click()
On Error GoTo Err_Command2_Click


Screen.PreviousControl.SetFocus
DoCmd.FindNext

Exit_Command2_Click:
Exit Sub

Err_Command2_Click:
MsgBox Err.Description
Resume Exit_Command2_Click

End Sub
Go to the top of the page
 
+
Girn13
post Aug 15 2006, 01:29 PM
Post #2

UtterAccess Guru
Posts: 700
From: Long Island NY, USA



Grafixx,
Have you looked at the Microsoft Date and Time Picker Control 6.0 (sp4). You'd create each of your date controls using it. It looks like a combo box but when you drop it down it shows a calendar from which you select a date. Once you click a date you're done.

HTH
Rick
Go to the top of the page
 
+
adamsherring
post Aug 15 2006, 02:13 PM
Post #3

VIP Emeritus
Posts: 1,750
From: The Great White North



Hi, check this db out.

You can call it like this :

private sub dateToCeo_click()
me.txtCeoDate = getDate
end sub

Hope this helps,

Adam
Attached File(s)
Attached File  DatePicker.zip ( 13.24K ) Number of downloads: 4
 
Go to the top of the page
 
+
Grafixx01
post Aug 15 2006, 03:08 PM
Post #4

UtterAccess Veteran
Posts: 450
From: Texas



That control isn't even on MS Access 2003.


**Thanks Adam, i'm going to try that once I get done with this other bs. This DB I'm making is like a HUGE undertaking besides having to handle 200+ computers & peripherals by myself! And they want me to make a MySQL, PHP forum too!
Go to the top of the page
 
+
Grafixx01
post Aug 16 2006, 01:42 PM
Post #5

UtterAccess Veteran
Posts: 450
From: Texas



Ok, I entered that in the VBA code for the text box on "txtDate_Closed" to see what would happen. It calls the calendar form up which is what I want. HOWEVER, the date when selected does not get entered into the txtDate_Closed text box. Code is below and the part that is the issue is in the second "Private Sub" at the point of calCalendar , it says compiler error.

Any clues?

CODE::

Option Compare Database
Option Explicit 'changed
Private strParentForm, strtextBox 'changed

Private Sub cmd_Insert_Date_Click()

Me.Visible = False 'changed
Forms(strParentForm).Controls(strtextBox).SetFocus 'changed
Forms(strParentForm).Controls(strtextBox).Text = CDate(calCalendar.Value) 'changed
DoCmd.Close acForm, Me.Name, acSaveNo 'changed

End Sub


Private Sub cmdExtCal_Click()
On Error GoTo Err_cmdExtCal_Click


DoCmd.Close acForm, Me.Name, acSaveNo 'changed (added acForm, Me.Name, acSaveNo


Exit_cmdExtCal_Click:
Exit Sub

Err_cmdExtCal_Click:
MsgBox Err.Description
Resume Exit_cmdExtCal_Click

End Sub
Go to the top of the page
 
+
adamsherring
post Aug 16 2006, 02:56 PM
Post #6

VIP Emeritus
Posts: 1,750
From: The Great White North



Hello,

Yes, I see problems.

First, where is the control 'calCalendar'? Second, you don't need to reference .Value, it is default, third, you cannot reference the .Text property unless the control has focus.

Where do you set the values of : strParentForm, strtextBox?

The insert Date button, is it on the form with the control referenced by strtextBox, or is it on the form with the calendar control?

Perhaps you should check out the db I posted to give you some hints.

Adam
Go to the top of the page
 
+
Grafixx01
post Aug 17 2006, 12:24 PM
Post #7

UtterAccess Veteran
Posts: 450
From: Texas



Adam,

Where is the db that you posted? Which one?

Also, the "Insert Date Button" is on the calendar form. It is supposed to insert the selected date in the different text box, however, there is different text boxes throughout the form.
Go to the top of the page
 
+
adamsherring
post Aug 17 2006, 01:09 PM
Post #8

VIP Emeritus
Posts: 1,750
From: The Great White North



Hi,

The db I've posted earlier in this thread.

I found, in my experience, it much easier to make a modular calendar object so I could use it again and again.

To that effect, I have command buttons beside text boxes where you can populate the date. So to use it, you'd click the date, it opens a form, you select the date, the form closes, and the date is placed in the textbox.

You could still use your approach (with the button on the form with the calendar), but you would have to pass the name of the control to your form so you could reference it.

Private Sub cmd_Insert_Date_Click()

Me.Visible = False 'changed
Forms(strParentForm).Controls(strtextBox).SetFocus 'changed --- dont need this
Forms(strParentForm).Controls(strtextBox).Text = CDate(calCalendar.Value) 'changed --- change this to :
Forms(strParentForm).Controls(strtextBox)= calCalendar

DoCmd.Close acForm, Me.Name, acSaveNo 'changed

End Sub

ok - next question - If you still want to use this method, what are strParentform and strTextbox? Where do they get populated?

And I suggest again, that you check out that db - it does exactly what you want and is easy to use

Adam
Go to the top of the page
 
+

Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Go to Top  ·  Lo-Fi Version Time is now: 25th May 2013 - 08:40 PM