Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

Calendar and textBox in one form

  Asked By: Lynne    Date: Feb 13    Category: MS Office    Views: 1263
  

I created a form called frmCalendar that shows a calendar with the
following codes:
Private Sub Calendar1_Click()
'transfers the date selected on the calendar to the active cell.
ActiveCell = Calendar1.Value
ActiveCell.NumberFormat = "mm/dd/yy"
' closes the form.
Unload Me
End Sub

Private Sub UserForm_Activate()
Me.Calendar1.Value = Date
End Sub

Private Sub UserForm_Initialize()
' to see if the active cell already contains a date.
'If it does, then the calendar will show the same date when it opens.
'If there is no date in the cell (or if what is in the cell isn't a
date) the calendar will show today's date.
If IsDate(ActiveCell.Value) Then
Calendar1.Value = DateValue(ActiveCell.Value)
Else
Calendar1.Value = Date
End If

End Sub

I have a new form called frmCowEnrollment with a textbox that the
user will use to enter a date.I would like to have the date enter
from the calendar.

When the user select a command button call cmdCallCalendar close to
the textBox, the frmCalendar will pop-up.Then the user will click a
date on the calendar that will become the value of the text box.

Private Sub cmdCallCalendar_Click()
frmCalendar.Show
If txtEnrollDate.Value = "" Then
txtEnrollDate.Value = Calendar1.Value

End If

End Sub

This section is not working, please could you help me.

Share: 

 

2 Answers Found

 
Answer #1    Answered By: Dang Tran     Answered On: Feb 13

You said "This section  is not working" Please say what is happening. Does
the calendar  appear? Do you get an error message (if so what?) does the date
get left blank or what?

 
Answer #2    Answered By: Jamie Roberts     Answered On: Feb 13

I think I see the problem:


Copy frmCalendar as frmCalendar2

Change all references to "ActiveCell" to
"frmCowEnrollment!txtEnrollDate.Value"

Make the calling sub:

Private Sub cmdCallCalendar_Click()
frmCalendar2.Show
End Sub

*Not tried*

 
Didn't find what you were looking for? Find more on Calendar and textBox in one form Or get search suggestion and latest updates.




Tagged: