OK, this one is bugging the heck out of me. This worked fine until two days ago, and now it just stopped and I can't get it to work.
Basically, I'm trying to do a couple of functions with a button. I want to:
Populate a couple of fields based on data that the user entered
Save the record
Print a form that is based on the record
Close the Form
I have the code listed below. The report has a criteria in the Primary Key field that specifies [Forms]![Register_Form]![Primary_Key] so it should only print the record I want (I tried some other stuff but that's a whole different subject).
When I click on the button, it appears to update the fields fine and saves the record. A quick "printing" dialog appears, but nothing prints and it stops at that point (won't exit the form).
I tried just creating a print button, but that doesn't work right, either. Yet I can print the form directly (if I enter the Primary_Key manually), so it does print.
What am I missing here?
Private Sub RegisterFOButton_Click()
On Error GoTo Err_RegisterFOButton_Click
' Populate fields before saving
Me.Date_Started = Now
If Me.Profile_Number = 99 Then
Me.Status = "Active"
Else
Me.Status = "Pending"
End If
Me.Primary_Key = Me.FONum & "-" & Me.SequenceNum & "-" & Me.Date_Started
' End populate fields
' Auto generated code - saves record
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
' End auto generated code
' Print report
DoCmd.OpenReport "Process_Sheet_Report_Generic", acViewNormal
' End Print report
DoCmd.Close
Exit_RegisterFOButton_Click:
Exit Sub
Err_RegisterFOButton_Click:
MsgBox Err.Description
Resume Exit_RegisterFOButton_Click
End Sub
Basically, I'm trying to do a couple of functions with a button. I want to:
Populate a couple of fields based on data that the user entered
Save the record
Print a form that is based on the record
Close the Form
I have the code listed below. The report has a criteria in the Primary Key field that specifies [Forms]![Register_Form]![Primary_Key] so it should only print the record I want (I tried some other stuff but that's a whole different subject).
When I click on the button, it appears to update the fields fine and saves the record. A quick "printing" dialog appears, but nothing prints and it stops at that point (won't exit the form).
I tried just creating a print button, but that doesn't work right, either. Yet I can print the form directly (if I enter the Primary_Key manually), so it does print.
What am I missing here?
Private Sub RegisterFOButton_Click()
On Error GoTo Err_RegisterFOButton_Click
' Populate fields before saving
Me.Date_Started = Now
If Me.Profile_Number = 99 Then
Me.Status = "Active"
Else
Me.Status = "Pending"
End If
Me.Primary_Key = Me.FONum & "-" & Me.SequenceNum & "-" & Me.Date_Started
' End populate fields
' Auto generated code - saves record
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
' End auto generated code
' Print report
DoCmd.OpenReport "Process_Sheet_Report_Generic", acViewNormal
' End Print report
DoCmd.Close
Exit_RegisterFOButton_Click:
Exit Sub
Err_RegisterFOButton_Click:
MsgBox Err.Description
Resume Exit_RegisterFOButton_Click
End Sub