Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / April 2005

Tip: Looking for answers? Try searching our database.

Invalid use of Null & runtime error 94

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
melwester - 08 Apr 2005 14:19 GMT
Hi Ken,

Still trying to get my dates to work.  With the code you supplied before
when I test it I do dates less then 2002 and more than 2005 (i.e 2000 or
2006) this works fine.  But when I try to erase the date to go to the next
field I get "Run time error 94 - Invalid use of Null message".

The user is going to have to be able to delete the date that is in the date
field and tab to the next field.

Here is the code:

Private Sub CADLDL_Date_Text_BeforeUpdate(Cancel As Integer)

Dim TextDate As Date
   TextDate = DateSerial(Right(Me!CAD_LDL_Date.Value, 4), _
              Left(Me!CAD_LDL_Date.Value, 2), _
              Mid(Me!CAD_LDL_Date.Value, 3, 2))
   Select Case TextDate
       Case #10/1/2002# To #9/30/2005#
           'do nothing'
           
       Case Else
           MsgBox "You have entered an invalid date."
           Cancel = True
       

   End Select
End Sub

Someone had mention changing the Cancel to = False, tried this and it still
doesn't work.   Have any ideas on this?

Thanks.
Wayne Morgan - 08 Apr 2005 14:28 GMT
>    TextDate = DateSerial(Right(Me!CAD_LDL_Date.Value, 4), _
>               Left(Me!CAD_LDL_Date.Value, 2), _
>               Mid(Me!CAD_LDL_Date.Value, 3, 2))

This is probably where your error message is coming from. You are trying to
assign a Null value to a date variable. One option would be to substitute a
value if the result is Null.

Example:
TextDate = Nz(DateSerial(Right(Me!CAD_LDL_Date.Value, 4), _
          Left(Me!CAD_LDL_Date.Value, 2), _
          Mid(Me!CAD_LDL_Date.Value, 3, 2)), Date)

This will pass today's date if the value is Null. Another option would be to
exit the routine if the textbox is Null.

Example:
If IsNull(Me!CAD_LDL_Date) Then Exit Sub

This is probably the better option if you want to allow the user to clear
the textbox and continue. You would place this before the "TextDate ="
statement.

Signature

Wayne Morgan
MS Access MVP

> Hi Ken,
>
[quoted text clipped - 31 lines]
>
> Thanks.
melwester - 08 Apr 2005 14:37 GMT
Thank you!!!!!  This works.  I used "If IsNull(Me!CAD_LDL_Date) Then Exit
Sub" before TextDate =

Thank you so much!!!

> >    TextDate = DateSerial(Right(Me!CAD_LDL_Date.Value, 4), _
> >               Left(Me!CAD_LDL_Date.Value, 2), _
[quoted text clipped - 54 lines]
> >
> > Thanks.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.