In this code which started on a different thread the program throws an error:
Invalid Use of Null:
The code is shown now
Code:
Option Compare Database
Option Explicit
Private Sub chkMeeting_Invite_Sent_AfterUpdate()
'Enable/disable Send Ticket command button
'if Ticket assigned checkbox is checked/unchecked
If Me.chkMeeting_Invite_Sent = -1 Then
Me.cmdSend_Email.Enabled = False
Else
Me.cmdSend_Email.Enabled = True
End If
End Sub
Private Sub btnClear_Click()
' Me.txtTo = Null
' Me.txtBody = Null
Me.txtAttachment = Null
End Sub
Private Sub cmdSend_Email_Click()
On Error GoTo Err_cmdSend_Email_Click
Dim stWhere As String '--Criteria for DLookup
Dim varTO As Variant '--Address for SendObject
Dim stText As String '--E-mail text
Dim RecDate As Variant '--Rec date for e-mail text
Dim stSubject As String '--Subject line of email
Dim StWho As String '--Reference to tblPersonnel
Dim strBranchhead As String ' Branchhead making meeting invite
Dim strSQL As String '--Create SQL update statement
Dim stMeetingID As String
Dim errLoop As Error
'-- Combo of name to send email to
StWho = Me.cboFullname
stWhere = "tblusers"
'--Looks up email address from Personnel Meeting Query
varTO = DLookup("stEmail", "", stWhere)
stSubject = ":: Meeting Invitation ::"
RecDate = Me.txtMeetingDate
'--Branchhead who emails invitation
strBranchhead = Me.cboBranchheads
stText = "You have neen invited to a meeting." & Chr$(13) & Chr$(13) & _
"Meeting: " & stMeetingID & Chr$(13) & _
"This mmmeting invitation has been sent to you by: " & strBranchhead & Chr$(13) & _
"Received Date: " & RecDate & Chr$(13) & Chr$(13) & _
"This is an automated message. Please do not respond to this e-mail."
'Write the e-mail content for sending to employee
DoCmd.SendObject , , acFormatTXT, varTO, , , stSubject, stText, -1
'Set the update statement to disable command button
'once email has been sent
strSQL = "UPDATE tblMeetingID, SET tblMeetingID.ysnMeeting_Invitite_SentID = -1 " & _
"Where tblMeetingID.lngMeetingID = " & Me.txtMeetingID & ";"
On Error GoTo Err_Execute
CurrentDb.Execute strSQL, dbFailOnError
On Error GoTo 0
'Requery checkbox to show checked
'after update statement has ran
'and disable send mail command button
Me.chkMeeting_Invite_Sent.Requery
Me.chkMeeting_Invite_Sent.SetFocus
Me.cmdSend_Email.Enabled = False
Exit Sub
Err_Execute:
' Notify user of any errors that result from
' executing the query
If DBEngine.Errors.Count > 0 Then
For Each errLoop In DBEngine.Errors
MsgBox "Error number: " & errLoop.Number & vbCr & _
errLoop.Description
Next errLoop
End If
Resume Next
Exit_cmdSend_Email_Click:
Exit Sub
Err_cmdSend_Email_Click:
MsgBox Err.Description
Resume Exit_cmdSend_Email_Click
End Sub
Private Sub Form_Current()
' Enable Send Ticket command button
' if meeting invite sent
' checkbox is not checked
If Me.chkMeeting_Invite_Sent = True Then
Me.cmdSend_Email.Enabled = False
Else
Me.cmdSend_Email.Enabled = True
End If
End Sub
Private Sub bntBrowse_Click()
Dim fileDiag As FileDialog
Dim file As Variant
Set fileDiag = FileDialog(msoFileDialogFilePicker)
fileDiag.AllowMultiSelect = False
If fileDiag.Show Then
For Each file In fileDiag.SelectedItems
Me.txtAttachment = file
Next
End If
End Sub
In the Private Sub cmdMailTciket_Click()
There are actually two
Exit Sub
lines. I put the command:
Exit_cmdSend_Email_Click:
above the second Exit Sub the one closest to the
End Sub
line.
It threw the error: Invalid Use of Null.
But it had no line designation as to where it actually occurred in the code.
So I am unsure what is going on. I posted the code and hopefully, that can show the error.
I do not see it.
Any help appreciated. Thanks in advance.
Respectfully,
Lou Reed