Creating a report from a selection made ina ComboBox

K

K Anand

Hi:
I have a combobox whose AfterUpdate event has the
following code:
Dim K1ByCompany As New Class1
Dim ByCom As String
Dim SQL_String As String
Dim stdocname As String
Dim stlinkcriteria As String
stdocname = "K1ByCompany"
ByCom = Me!cboByCom.Value

SQL_String = "SELECT Strengths.CompanyName,
Strengths.Date, Strengths.Subject, Strengths.Strength,
Strengths.AmtSaved, Strengths.Notes" & _
" FROM Strengths where
Strengths.CompanyName = """ & ByCom & """ "

K1ByCompany.CallK1RptByCom
DoCmd.OpenReport stdocname, , , stlinkcriteria

In my Class module is the following code:

Public Sub CallK1RptByCom()
Dim SQL_RptK1 As String

SQL_RptK1 = "SELECT Strengths.CompanyName, Strengths.Date,
Strengths.Subject, Strengths.Strength, Strengths.AmtSaved,
Strengths.Notes" & _
"FROM Strengths where Strengths.CompanyName =
[Forms]!Strengths.[cboByCom].[Value]));"
Reports(K1ByCompany).RecordSource = SQL_RptK1
End Sub

When I make a selection in the ComboBox, I get the
following Error message: Run-time Error 2457 The number
you used to refer to the report is invalid.

I have no clue as to where I am going wrong, PLEASE HELP!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top