OK, I'll tell you what i've got so far. On opening an Access Report I am running a Stored Procedure (a Select Query). Now my Recordset fields have values, but I cannot associate them to the controls I have placed on my Report. What am I doing wrong?? For example
strFamilyName=rs.Fields(2)
Here is the code when the Report opens, any help would be much appreciated
Private Sub Report_Open(Cancel As Integer)
' Retrieve family details by entering FamilyID
Dim Rs As ADODB.Recordset ' Recordset produces a virtual table from SELECT query
Dim FolderName, PicName As String
Dim strFamilyName, strAddress, strPostCode As String
Forms!frmWfsFamilyUpdate!txtFosterID.SetFocus
strFamilyID = Forms!frmWfsFamilyUpdate!txtFosterID.text
' Open a SQL Connection, to use a SELECT stored procedure.
sqlConnect
Set cmd = New ADODB.Command
cmd.ActiveConnection = Con
cmd.CommandType = adCmdStoredProc
cmd.CommandText = "selectFamilyDetails"
' CarerID variable inputted into
cmd.Parameters.Append cmd.CreateParameter("carerID", adVarChar, adParamInput, 8, strFamilyID)
' Run Stored Procedure
Set Rs = cmd.Execute
' If Recordset is not at end of file. Assign Report Controls to RS fieldNames
If Not Rs.EOF Then
strFamilyName = Rs.Fields(2)
strAddress = Rs.Fields(3)
strAddress = strAddress & "," & Rs.Fields(4)
strAddress = strAddress & "," & Rs.Fields(5)
strPostCode = Rs.Fields(6)
strPostCode = strPostCode & " " & Rs.Fields(7)
strPhoneNo = Rs.Fields(8)
End If
strFamilyName = txtFamilyName
strAddress = txtAddress
strPostCode=txtPostCode
strPhoneNo=txtPhoneNo
End Sub
strFamilyName=rs.Fields(2)
Here is the code when the Report opens, any help would be much appreciated
Private Sub Report_Open(Cancel As Integer)
' Retrieve family details by entering FamilyID
Dim Rs As ADODB.Recordset ' Recordset produces a virtual table from SELECT query
Dim FolderName, PicName As String
Dim strFamilyName, strAddress, strPostCode As String
Forms!frmWfsFamilyUpdate!txtFosterID.SetFocus
strFamilyID = Forms!frmWfsFamilyUpdate!txtFosterID.text
' Open a SQL Connection, to use a SELECT stored procedure.
sqlConnect
Set cmd = New ADODB.Command
cmd.ActiveConnection = Con
cmd.CommandType = adCmdStoredProc
cmd.CommandText = "selectFamilyDetails"
' CarerID variable inputted into
cmd.Parameters.Append cmd.CreateParameter("carerID", adVarChar, adParamInput, 8, strFamilyID)
' Run Stored Procedure
Set Rs = cmd.Execute
' If Recordset is not at end of file. Assign Report Controls to RS fieldNames
If Not Rs.EOF Then
strFamilyName = Rs.Fields(2)
strAddress = Rs.Fields(3)
strAddress = strAddress & "," & Rs.Fields(4)
strAddress = strAddress & "," & Rs.Fields(5)
strPostCode = Rs.Fields(6)
strPostCode = strPostCode & " " & Rs.Fields(7)
strPhoneNo = Rs.Fields(8)
End If
strFamilyName = txtFamilyName
strAddress = txtAddress
strPostCode=txtPostCode
strPhoneNo=txtPhoneNo
End Sub