T
Tony Williams
I have a form, frmviewid, on which there is a combo box, cmbidcard, which is
based on a table tblindividual. The row sorce of cmbidcard is
SELECT tblindividual.ID, [txtfirstname] & (" "+[txtsecondname]) & ("
"+[txtthirdname]) & (" "+[txtsurname]) AS Fullname FROM tblindividual;
There is a command button, cmdviewreport, that the user clicks to open a
report, rptIDCardForm. If the user selects a name from the combo box I want
the report to open for that person. If it is left blank I want the report to
include all the names. There is a control on my report called txtFullname
the row source for this is the same as the row source for cmbidcard ie
=[txtfirstname] & (" "+[txtsecondname]) & (" "+[txtthirdname]) & ("
"+[txtsurname])
If the value of cmbidcard = txtFullname then the report should only print
for that name.
However when I click on the command button I get a prompt asking me for the
value of txtFullname
Here is my code behind the OnClick event of the command button
Private Sub cmdviewreport_Click()
On Error GoTo Err_cmdviewreport_Click
Dim stDocName As String
stDocName = "rptIDCardForm"
DoCmd.OpenReport stDocName, acViewPreview, "",
Eval("IIf([Forms]![frmviewid]![cmbidcard] Is
Null,"""",""[TxtFullname]=Forms![frmviewid]![cmbidcard]"")")
Exit_cmdviewreport_Click:
Exit Sub
Err_cmdviewreport_Click:
MsgBox Err.Description
Resume Exit_cmdviewreport_Click
End Sub
Can anyone help?
Thanks
Tony
based on a table tblindividual. The row sorce of cmbidcard is
SELECT tblindividual.ID, [txtfirstname] & (" "+[txtsecondname]) & ("
"+[txtthirdname]) & (" "+[txtsurname]) AS Fullname FROM tblindividual;
There is a command button, cmdviewreport, that the user clicks to open a
report, rptIDCardForm. If the user selects a name from the combo box I want
the report to open for that person. If it is left blank I want the report to
include all the names. There is a control on my report called txtFullname
the row source for this is the same as the row source for cmbidcard ie
=[txtfirstname] & (" "+[txtsecondname]) & (" "+[txtthirdname]) & ("
"+[txtsurname])
If the value of cmbidcard = txtFullname then the report should only print
for that name.
However when I click on the command button I get a prompt asking me for the
value of txtFullname
Here is my code behind the OnClick event of the command button
Private Sub cmdviewreport_Click()
On Error GoTo Err_cmdviewreport_Click
Dim stDocName As String
stDocName = "rptIDCardForm"
DoCmd.OpenReport stDocName, acViewPreview, "",
Eval("IIf([Forms]![frmviewid]![cmbidcard] Is
Null,"""",""[TxtFullname]=Forms![frmviewid]![cmbidcard]"")")
Exit_cmdviewreport_Click:
Exit Sub
Err_cmdviewreport_Click:
MsgBox Err.Description
Resume Exit_cmdviewreport_Click
End Sub
Can anyone help?
Thanks
Tony