Calendar Not Appear On First Call

J

John G.

I'm using a calender control (v12) in a userform in XL2007. I'm not using a
separate userform for this calendar but included it as part of an initial
form asking for name, account #, and statement log date range. Name and
account # are selected from a dropdown and the form has two command buttons
for the Beginning and Ending dates of the log.

I take the Beginning and Ending date and concat them into a text string that
I display on the userform and again on the printout.

Note: This only happens when the form is first opened.

The problem: The calendar.visible is "false" at start up. When the Begin
button is clicked, the calendar does not show. When clicking in the area,
where the calendar should be, I get a day to appear, so this leads me to
believe that the visiblity call is working but the calendar is not showing.

If I initially double click on the begin button, the calendar shows but the
header with month and year are transparent.

If I click a date from either of the two above situations, the calendar is
turned off, as it should. When the Ending button is clicked, the full
calendar appears and everything is fine.

Also, you'll notice a reset button, it's there if it's needed by the user
and this is working fine.

Thx in advance, JG

Here's the code: (I apologize in advance if it's remedial but I don't make
my living doing this. :)...)

Private Sub StmtDtBegButton_Click()
With Calendar1
.Value = Date
.Visible = True
End With
End Sub

Private Sub StmtDtEndButton_Click()
With Calendar1
.Value = Date
.Visible = True
End With
End Sub

Public Sub StmtDtResetButton_Click()
With DateTxt
.Visible = False
.Value = ""
End With
BegDt = ""
EndDt = ""
StmtDates = ""
StmtDtBegButton.Visible = True
StmtDtEndButton.Visible = True
StmtDtResetButton.Visible = False
Label4.Visible = False
End Sub

Private Sub Calendar1_Click()
If DateTxt.Value = "" Then
StmtDtBegButton.Visible = False
StmtDtResetButton.Visible = True
BegDt = Format(Calendar1.Value, "mm/dd/yy")
Calendar1.Visible = False
DateTxt.Value = BegDt
Else
StmtDtEndButton.Visible = False
EndDt = Format(Calendar1.Value, "mm/dd/yy")
Calendar1.Visible = False
End If
If BegDt <> "" And EndDt <> "" Then
StmtDates = BegDt & " To " & EndDt
With DateTxt
.Value = StmtDates
.Visible = True
End With
Label4.Visible = True
End If
End Sub
 
P

Patrick Molloy

add the indicated line...

Private Sub StmtDtBegButton_Click()
With Calendar1
.Value = Date
.Visible = True
End With
Me.Repaint 'ADD THIS
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top