Unfortunately I can't take credit for this. Andy helped me. This is what i have in the forms code under "general" "print_orders_click"
I believe it's for several things 1) go to next record, 2) print current record 3) review orders 4) review all orders....
Any help--grateful!!!!! Robin.
Option Compare Database
Private Sub print_orders_Click()
On Error GoTo Err_print_orders_Click
DoCmd.PrintOut
Exit_print_orders_Click:
Exit Sub
Err_print_orders_Click:
MsgBox Err.Description
Resume Exit_print_orders_Click
End Sub
Private Sub Add_new_order_Click()
On Error GoTo Err_Add_new_order_Click
DoCmd.GoToRecord , , acNewRec
Exit_Add_new_order_Click:
Exit Sub
Err_Add_new_order_Click:
MsgBox Err.Description
Resume Exit_Add_new_order_Click
End Sub
Private Sub Next_Order_Click()
On Error GoTo Err_Next_Order_Click
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.PrintOut acSelection
Exit_print_orders_Click:
Exit Sub
Err_print_orders_Click:
MsgBox Err.Description
Resume Exit_print_orders_Click
End Sub
Private Sub Add_a_Order_Click()
On Error GoTo Err_Add_a_Order_Click
DoCmd.GoToRecord , , acNewRec
Exit_Add_a_Order_Click:
Exit Sub
Err_Add_a_Order_Click:
MsgBox Err.Description
Resume Exit_Add_a_Order_Click
End Sub
Private Sub Next_Orders_Click()
On Error GoTo Err_Next_Order_Click
DoCmd.GoToRecord , , acNext
Exit_Next_Order_Click:
Exit Sub
Err_Next_Order_Click:
MsgBox Err.Description
Resume Exit_Next_Order_Click
End Sub
Private Sub Command43_Click()
On Error GoTo Err_Command43_Click
DoCmd.GoToRecord , , acNewRec
Exit_Command43_Click:
Exit Sub
Err_Command43_Click:
MsgBox Err.Description
Resume Exit_Command43_Click
End Sub
Private Sub add_Click()
On Error GoTo Err_add_Click
DoCmd.GoToRecord , , acNewRec
Exit_add_Click:
Exit Sub
Err_add_Click:
MsgBox Err.Description
Resume Exit_add_Click
End Sub
Private Sub next_Click()
With Recordset
.MoveNext
If .EOF Then MsgBox "No More Records", vbInformation
End With
End Sub
Private Sub printcurrent_Click()
On Error GoTo Err_printcurrent_Click
Dim strDocName As String
Dim strLinkCriteria As String
strDocName = "Current Record"
strLinkCriteria = "[OrderID] = Forms![Medication Orders]![OrderID]"
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
DoCmd.OpenReport strDocName, acNormal, , strLinkCriteria
Exit_print_Click:
Exit Sub
Exit_printcurrent_Click:
Exit Sub
Err_printcurrent_Click:
MsgBox Err.Description
Resume Exit_printcurrent_Click
End Sub
Private Sub preview_Click()
On Error GoTo Err_preview_Click
Dim strDocName As String
Dim strLinkCriteria As String
strDocName = "Current Record"
strLinkCriteria = "[Order ID] = Forms![Medication Orders]![OrderID]"
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
DoCmd.OpenReport strDocName, acPreview, , strLinkCriteria
Exit_preview_Click:
Exit Sub
Err_preview_Click:
MsgBox Err.Description
Resume Exit_preview_Click
End Sub
Private Sub save_Click()
On Error GoTo Err_save_Click
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Exit_save_Click:
Exit Sub
Err_save_Click:
MsgBox Err.Description
Resume Exit_save_Click
End Sub
Private Sub Command53_Click()
On Error GoTo Err_Command53_Click
Dim stDocName As String
stDocName = "All orders by date"
DoCmd.OpenReport stDocName, acPreview
Exit_Command53_Click:
Exit Sub
Err_Command53_Click:
MsgBox Err.Description
Resume Exit_Command53_Click
End Sub
Private Sub print_orders_Click()
On Error GoTo Err_print_orders_Click
Dim stDocName As String
Dim MyForm As Form
stDocName = "Medication Orders"
Set MyForm = Screen.ActiveForm
DoCmd.SelectObject acForm, stDocName, True
DoCmd.PrintOut
DoCmd.SelectObject acForm, MyForm.Name, False
Exit_print_orders_Click:
Exit Sub
Err_print_orders_Click:
MsgBox Err.Description
Resume Exit_print_orders_Click
End Sub