*NEW* invalid use of null error

anthonyevans

Registered User.
Local time
Today, 14:00
Joined
Mar 15, 2001
Messages
29
Dear All,
I am getting an 'invalid use of null' error on clicking the button with the following underlying code. What is the problem here ?

Private Sub accidentreport_Click()
On Error GoTo Err_accidentreport_Click

Dim stDocName As String
Dim stLinkCriteria As String
Dim c, d As Date
Dim a, b, f, g, h As String
Dim e As Date

a = Me![First_Name]
b = Me![Surname]
c = Me![Date_Of_Birth]
d = Me![Date_Of_Incident]
e = Me![Time_Of_Incident]
f = Me![Company_Or_Production_Name]
g = Me![Location_Of_The_Incident]
h = Me![Condition_Reason_For_Attendance]
stDocName = "Accident Report Form"

stLinkCriteria = "[Serial_Number]=" & Me![Serial_Number]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Forms![Accident Report Form]![First_Name] = a
Forms![Accident Report Form]![Surname] = b
Forms![Accident Report Form]![Date_Of_Birth] = c
Forms![Accident Report Form]![Date_Of_Incident] = d
Forms![Accident Report Form]![Time_Of_Incident] = e
Forms![Accident Report Form]![Company_Or_Production_Name] = f
Forms![Accident Report Form]![Location_Of_The_Incident] = g
Forms![Accident Report Form]![Condition_Reason_For_Attendance] = h
Forms![Accident Report Form].Refresh

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

stDocName = "Treatment Report"
DoCmd.OpenReport stDocName, acNormal, , "[Serial_Number] = [forms]![TREATMENT FORM]![Serial_Number]"

DoCmd.Close acForm, "TREATMENT FORM"


Exit_accidentreport_Click:
Exit Sub

Err_accidentreport_Click:
MsgBox Err.Description
Resume Exit_accidentreport_Click

End Sub

Thankyou in advance for your help,

Anthony
 
You might want to disable error trapping, so that Access will highlight the offending statement when the error occurs. My shoot-from-the-hip guess would be that you have a Null value in the arguments for either the DoCmd.OpenForm or DoCmd.OpenReport statement.
 
Dear AlanS,

I seem to have figured out solving the problem by putting the 'DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70' piece of code above the DIM statements.

Seems to work now.

Thanks for your help,

Anthony
 

Users who are viewing this thread

Back
Top Bottom