anthonyevans
Registered User.
- Local time
- Today, 18:09
- Joined
- Mar 15, 2001
- Messages
- 29
Dear All, I know this is a bit long winded but it might be the best way to express the problem. I need a button that will save the current data, close the form, print a report and goto to another form. I have the code for all three in seperate buttons but need to combine them into one.
Here is the code for the button going to the other form taking some data with it. It is within this code that i wish to add the other fuctions :
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
Exit_accidentreport_Click:
Exit Sub
Err_accidentreport_Click:
MsgBox Err.Description
Resume Exit_accidentreport_Click
End Sub
Here is the code for the printing of the report :
Private Sub printreport_Click()
On Error GoTo Err_printreport_Click
Dim stDocName As String
stDocName = "Treatment Report"
DoCmd.OpenReport stDocName, acNormal, , "[Serial_Number] = [forms]![TREATMENT FORM]![Serial_Number]"
Exit_printreport_Click:
Exit Sub
Err_printreport_Click:
MsgBox Err.Description
Resume Exit_printreport_Click
End Sub
And finally the code for closing the form :
Private Sub closerecord_Click()
On Error GoTo Err_closerecord_Click
DoCmd.Close
Exit_closerecord_Click:
Exit Sub
Err_closerecord_Click:
MsgBox Err.Description
Resume Exit_closerecord_Click
End Sub
Now I'd like to put the two above button codes into the first chunk of code.
If anyone has the time to advise I would be most grateful.
Anthony
Here is the code for the button going to the other form taking some data with it. It is within this code that i wish to add the other fuctions :
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
Exit_accidentreport_Click:
Exit Sub
Err_accidentreport_Click:
MsgBox Err.Description
Resume Exit_accidentreport_Click
End Sub
Here is the code for the printing of the report :
Private Sub printreport_Click()
On Error GoTo Err_printreport_Click
Dim stDocName As String
stDocName = "Treatment Report"
DoCmd.OpenReport stDocName, acNormal, , "[Serial_Number] = [forms]![TREATMENT FORM]![Serial_Number]"
Exit_printreport_Click:
Exit Sub
Err_printreport_Click:
MsgBox Err.Description
Resume Exit_printreport_Click
End Sub
And finally the code for closing the form :
Private Sub closerecord_Click()
On Error GoTo Err_closerecord_Click
DoCmd.Close
Exit_closerecord_Click:
Exit Sub
Err_closerecord_Click:
MsgBox Err.Description
Resume Exit_closerecord_Click
End Sub
Now I'd like to put the two above button codes into the first chunk of code.
If anyone has the time to advise I would be most grateful.
Anthony