Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
blinton25
Yak Posting Veteran
90 Posts |
Posted - 2004-04-03 : 18:15:49
|
Hello,How are you today?I am running a query in my Report OnOpen Event to set the record source for a report. However I think I am receiving a blank recordset. I wrote a function to test this but my recordset comes back with the correct results.1. Does anything about this code look incorrect?Private Sub Report_Open(Cancel As Integer) ' Create underlying recordset for report using criteria entered in Dim intX As Integer Dim qdf As QueryDef Dim frm As Form ' Set database variable to current database. Set dbsReport = CurrentDb Set frm = Forms!DateRangePreviousCurrentYear ' Open QueryDef object. Set qdf = dbsReport.QueryDefs("TArrivalsByRegion") qdf.SQL = "EXEC TArrivalsByRegion " & Forms!DateRangePreviousCurrentYear!PrevYear & "," & Forms!DateRangePreviousCurrentYear!CurrYear ' Open Recordset object. Set rstReport = qdf.OpenRecordset() 2. Anyway I can take a look at what recordset is coming back from my Querydef? |
|
jhermiz
3564 Posts |
Posted - 2004-04-26 : 16:18:31
|
Don't know why you are doing it like this...Do something like this:if IsNull(Forms!frmMain!cboCustomers) then strSQL = "SELECT * FROM Customers"else strSQL = "SELECT * FROM Customers WHERE CustomerName= '" & Forms!frmMain!cboCustomers & "'"end ifMe.Recordsource = strSQL You do not need a query def. object...generate your SQL on the fly...and set the reports recordsource property to the sql string.I have done this on a reports criteria form allowing my end users to select from combo boxes to reveal reports that are filtered to fit there needs.Jon |
 |
|
|
|
|