×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Invalid Use of NULL error on event procedure

Invalid Use of NULL error on event procedure

Invalid Use of NULL error on event procedure

(OP)
Hello,

I'm not sure if this is the correct area to be posting this in, but I thought I would see what help I can get. I've inherited a database (built by someone no longer with the company) that is used for recruiting purposes, but there is a portion of it that appears to not be functioning properly.

In the database there is a button to e-mail roster information, but upon clicking it, it gives an error of "Invalid Use of Null" (something similar to that - I don't have the exact error at this time which I know would be helpful).

When doing a debug of that error, it highlights the following portion of code:

CODE -->

strBody = DA.CreateRosterEmail(classID) 

Looking at the code, I was able to see the following sections that appear to work in conjunction with each other

CODE

Private Sub EmailRosterDetails_Click()
    Dim DA As DataAccess
    Dim oLook As Object
    Dim oMail As Object
    Dim olns As Outlook.NameSpace
    Dim strBody As String
    Dim emailSubject As String
    
    Set DA = New DataAccess
    
    strBody = DA.CreateRosterEmail(classID)
    
    If Not strBody = "" Then
        Set oLook = CreateObject("Outlook.Application")
        Set olns = oLook.GetNamespace("MAPI")
        Set oMail = oLook.CreateItem(0)
        
        
        emailSubject = "Class Roster - " & DA.getClassDateByClassID(classID)

        With oMail
            .To = agentEmailAddress
            .Subject = emailSubject
            .HTMLBody = strBody
            .Display
        End With
        MsgBox "Recruiting email report is being generated. Please check your outlook."
    Else
        MsgBox "There are no open classes to report on."
    End If
End Sub 

The hightlighted area mentioned points to a module where the following was found:

CODE

Public Function CreateRosterEmail(classID As Double) As String
    Dim reportString As String
    Dim rosterRec As Recordset
    Dim lunchString As String
    
    Me.CreateRosterRecordSet classID, rosterRec
    
    If Not (rosterRec.EOF And rosterRec.BOF) Then
        
        reportString = "<HTML><head><meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'>"
        reportString = reportString & "<style><!--table{font-family: 'Calibri', serif;font-size: 14px;table-layout: fixed;border: 1px solid #003057;}"
        reportString = reportString & "td {border: 1px solid #003057;border-collapse: collapse;padding: 5px;}"
        reportString = reportString & "td.bottom {height: 100px;text-align: left;vertical-align: top;padding: 5px;}--></style>"
        reportString = reportString & "<table><tr><td style='font-weight: bold; background-color: #b3d9ff; width: 140px;'>LastName</td>"
        reportString = reportString & "<td style='font-weight: bold; background-color: #b3d9ff; width: 140px;'>FirstName</td>"
        reportString = reportString & "<td style='font-weight: bold; background-color: #b3d9ff; width: 80px;'>ID1</td>"
        reportString = reportString & "<td style='font-weight: bold; background-color: #b3d9ff; width: 80px;'>ID2</td>"
        reportString = reportString & "<td style='font-weight: bold; background-color: #b3d9ff; width: 80px;'>ID3</td>"
        reportString = reportString & "<td style='font-weight: bold; background-color: #b3d9ff; width: 140px;'>WorkEmail</td>"
        reportString = reportString & "<td style='font-weight: bold; background-color: #b3d9ff; width: 250px;'>Schedule</td>"
        reportString = reportString & "<td style='font-weight: bold; background-color: #b3d9ff; width: 200px;'>Lunch/Dessert</td></tr>"
        rosterRec.MoveFirst
        Do While Not rosterRec.EOF
            If Not rosterRec!meal = "" Then
                lunchString = rosterRec!meal & ", " & rosterRec!dessert
            Else
                lunchString = ""
            End If
            reportString = reportString & "<tr><td>" & rosterRec!lastName & "</td><td>" & rosterRec!firstName & "</td><td>" & rosterRec!id1 & "</td><td>"
            reportString = reportString & rosterRec!id2 & "</td><td>" & rosterRec!id3 & "</td><td>" & rosterRec!workEmail & "</td><td>"
            reportString = reportString & Me.GetScheduleByScheduleID(rosterRec!scheduleID) & "</td><td>" & lunchString & "</td></tr>"
            rosterRec.MoveNext
        Loop
        reportString = reportString & "</table>"
    Else
        reportString = ""
    End If
    
    CreateRosterEmail = reportString
End Function 

As mentioned, I inherited this from someone else and I'm just trying to fix this portion of the database as it could prove helpful. I'm just trying to get a general idea as to what is holding up getting the e-mail roster button to work (and hopefully get it fixed). Let me know if there is any additional information.

Thanks in advance!

RE: Invalid Use of NULL error on event procedure

1. Check classID value you try to pass to procedure,
2. Try to raise error trapping setting to "break in class module" or higher (Tools>Options, "General" tab). This will allow break in CreateRosterEmail if error occurs here,
3. Check references, sometimes missing references generate unexpected errors.

combo

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close