sacacompany
Member
- Local time
- Today, 19:25
- Joined
- Dec 28, 2022
- Messages
- 31
can i have a report in access based on sql server view that is being open/retrieved bis connection string
This bit won't work as you think, if it were to work at all.Code:' ... ' Check if any records are found If Not rs.EOF Then ' Set the record source of the report to the SQL query Me.RecordSource = strSQL End If ' ...
' ...
' Check if any records are found
If Not rs.EOF Then
' Set the recordset of the report to the recordset object
Set Me.Recordset = rs
End If
' ...
' ...
' Set the SQL query
strSQL = "SELECT * FROM MC_PrescriptionQ ;"
' Create a temporary query
With CurrentDb.CreateQueryDef(vbNullString)
.Connect = DBcon
.SQL = strSQL
.ReturnsRecords = True
' Open the recordset
Set rs = .OpenRecordset
End With
' Check if any records are found
If Not rs.EOF Then
' Set the record source of the report to the SQL query
Set Me.Recordset = rs
End If
' ...
ADP not available...temp table work around looks good...can u please elaborate ....thanksYou can't set the Report.RecordSet property unless it is an ADP Database.
Workaround:
Link the view(MC_PrescriptionQ) then your code can set the Report.RecordSource property (or use a DAO Pass-Through query or a temp table with data from ADO query).
yes the BE is on LAN SQL server ...please guide me to correct what you feel i m doing incorrectlyIs the BE on a LAN? If so, you were doing something very wrong.
strSQL = "SELECT * FROM MC_PrescriptionQ ;"
rs.Open strSQL, DBCon, 1, 3
' Check if any records are found
If Not rs.EOF Then
' Set the record source of the report to the SQL query
Me.RecordSource = strSQL
End If