I am trying to use a qry as a recordsource. The qry uses a query(qryVATLett) based on 2 tables + 2 other tables. I think I am getting this error message because of the query. Any ideas?
Sicando
Dim rpt As Report, rst As Recordset, db As Database, rst1 As Recordset, strSQL As String
Dim strQry As String
Dim strDate1 As Date, strDate2 As Date
greg is right. where is this code that is running. is it on the report that is opening? is it behind a button? where is it?
as Greg points out, you never set the report variable (rpt) to anything. you need to set rpt = to the report you are trying to open, but depending on where your code is located there are different ways to do it.
i don't think greg's code will work for you though, as his idea is to open the report in preview mode first. if you do this, THEN set the recordsource, the report won't requery.
i think that you should move your code to the On Open event of your report. then, simply change your
rpt.RecordSource = strSQL
to
Me.RecordSource = strSQL
enjoy
dovholuk
0
sicandoAuthor Commented:
Dough! SQL was wrong as well
Okay
0
Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.
Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.
I have a code called Company. Here is my code
Dim rpt As Report
DoCmd.OpenReport "Company", acViewPreview
Set rpt = Reports("Company")
rpt.RecordSource = strSQL
See how that goes!
Greg