First of all, no matter what, when you assign a value to the recordsource
property, the value must be expressed as a string. You did not so whatever
your code was, it could not work.
Second the logic is wrong in your code. In an If statement, what follows the
keyword "Then" only executes if what follows the "If" keyword is true. If it
is false, execution IMMEDIATELY jumps to "End If". Now let's take a look at
your code.
If you choose "Original" in the combobox, the statement is True. So
Me.RecordSource = qryBilling executes. Also since the "Amended" If statement
immediately follows before the "End If" of the "Original" if statement, the
"Amended" if statement also executes. The "Amended" if statement has to be
False because you chose "Original" so the "Amended" if statement immediately
jumps to the upper "End If". Executes then proceeds to the bottom "End If".
At the conclusion of execution of code, the record source of your report is
qryBilling.
If you choose "Amended" in the combobox, the statement is False. So the
"Original" if statement immediately jumps to the lower "End If". The
"Amended" If statement is totally bypassed and is not executed. At the
conclusion of execution of code, the record source of your report is
whatever is set in the properties of the report.
If you wanted to use the If/Then construct to set the recordsource, your
code needs to look like:
If Forms!frmReportType!cboReport = "Original" Then
Me.RecordSource = "qryBilling"
ElseIf If Forms!frmReportType!cboReport = "Amended" Then
Me.RecordSource = "qryBillingAMENDED"
Else
MsgBox "The Value Of The ComboBox Is Not Original Or Amended"
End If
Steve
(e-mail address removed)
Tara, I provide help with Access, Excel and Word applications for a small
fee. I specialize in fixing problems in existing applications, modifying
existing applications and adding new functionality to existing applications.
If ever you need immediate help, contact me.