Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Invalid use of Null

Status
Not open for further replies.

wabtrainer

IS-IT--Management
Feb 4, 2002
66
GB
I have a text box for a Date on a form.
When the field has focus an activeX calendar becomes visible to allow the date to be selected, but when I enter the textbox i get a message "Runtime error 94 invalid use of Null.
The relevant pieces of code are:
Private Sub ActiveXCtl18_AfterUpdate()
Me!Date = ActiveXCtl18.Value
Me!Date.SetFocus
' Close the calendar after picking a new valid date
Me!ActiveXCtl18.Visible = False
End Sub
Private Sub Date_BeforeUpdate(Cancel As Integer)
If Not Me!ActiveXCtl18.Object.Value Then
Cancel = True
End If


End Sub
Private Sub Date_GotFocus()
Me!ActiveXCtl18.Visible = True
If IsNull(Me!Date) Then
' Set date to today as a default
Me!ActiveXCtl18.Year = Year(Date)
Me!ActiveXCtl18.Month = Month(Date)
Me!ActiveXCtl18.Value = Date
End If
End Sub

Anyone know what I am doing wrong????
 
Hi,

Not exactly but I had a similar problem recently by naming something 'Date'.

It appears that you have named one of the controls on the form as Date, I changed mine to myDate and it was OK.

Also I had problems refering to 'Date()' in the forms class module, it kept comming up as null. I have to lead it out to a proc in a std module and pass the date back.

Hope it helps

Dan
 
ThanX, I have changed the controls name but am still getting the same message.
It is confusing me as I have the same control working on another form fine. If you want to be a bear:
Be a Grizzly!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top