VBA Coding for Calendar

N

na

I will admit I am VBA challanged so I copied code from an example to have a
command button call up the activex calendar in Access and and populate a text
field. The example however, assumed I only had one field that needed a date.
On my form I have a total of 3 fields that need dates. I have created
command buttons for all three and with the code below I am all set for the
first box but not the other two. The samples I've seen on the web don't
address this and I want to avoid using a combo box to call up the calander.
Here is the code I have:
Option Compare Database
Option Explicit

Private Sub calCtl1_Click()
Me.Text2 = Me.calCtl1.Value
Me.Text2.SetFocus
Me.calCtl1.Visible = False
End Sub

Private Sub cmdCal_Click()
On Error GoTo Err_cmdCal_Click

Me.calCtl1.Visible = True

If Not IsNull(Me.Text2) Then
Me.calCtl1.Value = Me.Text2
Else
Me.calCtl1.Value = Date
End If

Exit_cmdCal_Click:
Exit Sub

Err_cmdCal_Click:
MsgBox Err.Description
Resume Exit_cmdCal_Click

End Sub


I truly have looked for a solution and am at my wit's end - as I said VBA is
not my strong suit. Can someone point me in the right direction?

Thanks
 
J

Jim Shaw

Part of the problem is that the control never returns a "NULL" value. When
I ran a trace and examined the control, it would sometimes return a value of
"empty".
I'm not sure an IF IsEmpty() function is available...does anyone know of
one? I couldn't find a reference to one in the VB Help index.
Jim
 

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