When I first set about this project I was advised to use a Union Query as the Record Source for my Report. On my test system I ran the SQL server local to the client front end. Everything seemed fine, however now I have migrated the Database on to the Live Server, I can no longer print reports.
I'm sure I need to use Adodb but I'm unsure of the Syntax.
Here's my code.
Expand|Select|Wrap|Line Numbers
- Private Sub cmdPrint_Click()
- ' Prints FactSheet to be given to Foster Children
- Dim db As DAO.Database
- Dim qd As DAO.QueryDef
- Dim stReportName As String
- Dim StrCarerID As String
- Me.txtFosterID.SetFocus
- StrCarerID = Me.txtFosterID.text
- Val (StrCarerID)
- ' Run Stored Procedure
- If Len(StrCarerID) Then
- Set db = DBEngine(0)(0)
- Set qd = db.QueryDefs("qryViewFosterFamily")
- qd.sql = "EXEC dbo.sp_ViewFosterFamily" & " " & StrCarerID
- Debug.Print qd.sql
- db.QueryDefs.Refresh
- stReportName = "rptFactSheet"
- DoCmd.OpenReport stReportName, acViewPreview, , , acWindowNormal
- Set qd = Nothing
- Set db = Nothing
- Else
- MsgBox "No Family Details Entered....", vbCritical, "Print Error"
- End If
- End Sub