Hi All!
I am experiencing a problem that I am hoping someone can shed some light on. I have used the Onclick event to print the current record of a form and the code works great for every parameter on the form except my unique identifier (which happens to be the ID - autonumber field). I have used this exact same code in another database to do the same thing without too much trouble however on the current database I keep getting the "Enter Parameter Value" dialogue box open when I execute.
It is asking for a user input instead of automatically using the value from the current open form.
As I have said I have tried using another (non-unique) field and the code works without activating the "Enter Parameter Value" prompt. I have also tried changing the name of the ID field with no avail. Below is the code, any chance someone here knows what I need to fix to get the code to automatically select the current record using the autonumber field?
Thanks in advance...
Private Sub CalculateResults_Click()
On Error GoTo Err_CalculateResults_Click
Dim strWhere As String
strWhere = "[ID]=" & Me!ID
DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenReport "DQCCResults", acPreview, , strWhere
DoCmd.PrintOut acPrintAll, , , acHigh, 1
DoCmd.SendObject acSendReport, , acFormatRTF, "Joe Smith", , , "DQCC Results",
, False
DoCmd.Close acReport, "DQCCResults", acSaveYes
DoCmd.Close acForm, "DQCCDataEntry", acSaveYes
Exit_CalculateResults_Click:
Exit Sub
Err_CalculateResults_Click:
MsgBox Err.Description
Resume Exit_CalculateResults_Click
End Sub
I am experiencing a problem that I am hoping someone can shed some light on. I have used the Onclick event to print the current record of a form and the code works great for every parameter on the form except my unique identifier (which happens to be the ID - autonumber field). I have used this exact same code in another database to do the same thing without too much trouble however on the current database I keep getting the "Enter Parameter Value" dialogue box open when I execute.
It is asking for a user input instead of automatically using the value from the current open form.
As I have said I have tried using another (non-unique) field and the code works without activating the "Enter Parameter Value" prompt. I have also tried changing the name of the ID field with no avail. Below is the code, any chance someone here knows what I need to fix to get the code to automatically select the current record using the autonumber field?
Thanks in advance...
Private Sub CalculateResults_Click()
On Error GoTo Err_CalculateResults_Click
Dim strWhere As String
strWhere = "[ID]=" & Me!ID
DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenReport "DQCCResults", acPreview, , strWhere
DoCmd.PrintOut acPrintAll, , , acHigh, 1
DoCmd.SendObject acSendReport, , acFormatRTF, "Joe Smith", , , "DQCC Results",
, False
DoCmd.Close acReport, "DQCCResults", acSaveYes
DoCmd.Close acForm, "DQCCDataEntry", acSaveYes
Exit_CalculateResults_Click:
Exit Sub
Err_CalculateResults_Click:
MsgBox Err.Description
Resume Exit_CalculateResults_Click
End Sub