K
Kaden
Thanks all for the advice in a Open Report with current Record thread.
Instead of highjacking that one I decided to start a new one for help with a
related issue I am having.
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 in another
database to do the same thing without too much trouble however on the current
database I keep getting the Parameter Query 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 Parameter Query 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
Instead of highjacking that one I decided to start a new one for help with a
related issue I am having.
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 in another
database to do the same thing without too much trouble however on the current
database I keep getting the Parameter Query 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 Parameter Query 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