?
Solved

Error 94 Invalid use of Null

Posted on 2005-04-21
11
Medium Priority
?
616 Views
Last Modified: 2012-05-05
I have a button in Access that runs this piece of code:

Private Sub Outlook_Click()
On Error GoTo Add_Err

    'Save record first to be sure required fields are filled.
    DoCmd.RunCommand acCmdSaveRecord

        Dim objOutlook As Outlook.Application
        Dim objAppt As Outlook.AppointmentItem
        Dim objRecurPattern As Outlook.RecurrencePattern

        Set objOutlook = CreateObject("Outlook.Application")
        Set objAppt = objOutlook.CreateItem(olAppointmentItem)

        With objAppt
            .Start = Me!datetobecompleted & " " & Me!StartTime
            .Duration = Me!DurationTime
            .Subject = Me!Device
            .Save
            .Close (olSave)
            End With
            'Release the AppointmentItem object variable.
            Set objAppt = Nothing
 
   'Release the Outlook object variable.
    Set objOutlook = Nothing

       'save the record, display a message.
    DoCmd.RunCommand acCmdSaveRecord
    MsgBox "Appointment Added!"

    Exit Sub

Add_Err:
    MsgBox "Error " & Err.Number & vbCrLf & Err.Description
    Exit Sub

End Sub

====

However, when I run it, it comes up with an error saying "Error 94 - Invalid use of Null"

Why am I getting this?????

Many thanks,

Bob...
0
Comment
Question by:bob_the_builder
  • 4
  • 2
  • 2
  • +3
11 Comments
 
LVL 16

Expert Comment

by:Calvin Brine
ID: 13834603
What line of code does the error appear on? You will need to disable your error checking to get the access debug dialog.  Let me know where the error occurs.

Cal
0
 
LVL 51

Expert Comment

by:Steve Bink
ID: 13834606
Which line is returning that error?  Chances are, it is one of these:

            .Start = Me!datetobecompleted & " " & Me!StartTime
            .Duration = Me!DurationTime
            .Subject = Me!Device

You should make sure that the current record has those fields filled out, or account for the possibility of a NULL value in the assignment like this:

            .Start = Nz(Me!datetobecompleted, "") & " " & Nz(Me!StartTime, "")
            .Duration = Nz(Me!DurationTime, "")
            .Subject = Nz(Me!Device, "")

Repalce the "" with 0 for numeric data.
0
 
LVL 2

Accepted Solution

by:
livvie earned 200 total points
ID: 13834607
probably because you are trying to save a record that has a null value in a field that null values aren't allowed.
Debug and check these :
Me!datetobecompleted & " " & Me!StartTime
Me!DurationTime
Me!Device
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 26

Expert Comment

by:dannywareham
ID: 13834616
Take the error trap out.
Where does the code fall over?
I believe it will be in one of these lines@:

            .Start = Me!datetobecompleted & " " & Me!StartTime
            .Duration = Me!DurationTime
            .Subject = Me!Device

Where your control has a null value.

If so, change to:

            .Start = NZ(Me!datetobecompleted,"No Data") & " " & NZ(Me!StartTime,"No Data")
            .Duration = NZ(Me!DurationTime,"No Data")
            .Subject = NZ(Me!Device,"No Data")

If you have a null value, it will put "No Data" in the message.

You could us IsNull(value) to exit the sub from an IF statement, if you wanted.

:-)
0
 
LVL 26

Expert Comment

by:dannywareham
ID: 13834620
routinet - get out of my head
0
 
LVL 26

Expert Comment

by:dannywareham
ID: 13834624
..and you livvie
0
 
LVL 66

Expert Comment

by:Jim Horn
ID: 13834629
Without getting into your code, please do this...

(1)  Place a breakpoint by clicking once on the first actionable line in your code (DoCmd.RunCommand...)
(2)  Run the code, and execution will Stop at that line.  You'll see a yellow bar at that line to signify that's where you are in code execution.
(3)  Hit your {f8} button, and the yellow bar will 'step' from one line to the next.  This is called 'stepping through code'
(4)  Keep hitting your {f8} button until you get your error message again, then post in this question that line.

Hope this helps.
-Jim
0
 
LVL 66

Expert Comment

by:Jim Horn
ID: 13834639
(sorry boys.. way too slow)
0
 
LVL 26

Expert Comment

by:dannywareham
ID: 13834789
Yours is far moer organised Jim
Ours are a quick and dirty check

:-)
0
 
LVL 10

Author Comment

by:bob_the_builder
ID: 13834868
Thank you all for your quick response....Basically I were being an idiot and not filling out all the fields correctly....So yes, One of the fields contained a null value..

Many thanks,

Bob...
0
 
LVL 51

Expert Comment

by:Steve Bink
ID: 13835143
First, best aye....<sigh>
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Windows Explorer let you handle zip folders nearly as any other folder: Copy, move, change, and delete, etc. In VBA you can also handle normal files and folders, but zip folders takes a little more - and that you'll find here.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Suggested Courses

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question