Hi everyone,
I am having a problem setting a DAO record set to a subform and displaying the results
I have both the main form and the subform unbound.
I populate 3 combo boxes, then I use what ever the user has selected from those combo boxes to set up a search.
Here is my code:
I checked the record set and it returns records. however I can't get to display the resuts in the sub form.
The fields in the sub form show up as #name?
What Am I doing wrong??
I have attached an image.
Thanks in advance.
EG
I am having a problem setting a DAO record set to a subform and displaying the results
I have both the main form and the subform unbound.
I populate 3 combo boxes, then I use what ever the user has selected from those combo boxes to set up a search.
Here is my code:
Code:
Dim ITPDB As DAO.Database
Dim ITPRS As DAO.Recordset
Dim strQuery As String
On Error GoTo ErrorHandler
Set ITPDB = currentdb()
Screen.MousePointer = 11 'vbhourglass
strQuery = "SELECT LotNumber, FormName, SubFormName, SubField, ImagePath, ImageName FROM ITP " & _
"WHERE LotNumber = '" & Trim(cmbLotNumber.Value) & "'" & _
" AND FormName = '" & Trim(cmbFormName.Value) & "'" & _
" AND SubFormName = '" & Trim(cmbSubform.Value) & "' ORDER BY FormName;"
Set ITPRS = ITPDB.OpenRecordset(strQuery)
If ITPRS.RecordCount <= 0 And ITPRS.EOF Then
GoTo ExitHere
End If
Set Me.ITPSearchResultsSubForm.Form.Recordset = ITPRS
ITPSearchResultsSubForm.Visible = True
ExitHere:
Screen.MousePointer = 0 'default
If Not ITPRS Is Nothing Then
ITPRS.Close
Set ITPRS = Nothing
End If
If Not ITPDB Is Nothing Then
ITPDB.Close
Set ITPDB = Nothing
End If
'MsgBox "Number Of Dups Found = " & lNofDups
Exit Sub
ErrorHandler:
If Err.Number = 3704 Then
Resume Next
Else
Call HandleUnexpectedError(Err.Number, Err.Description)
End If
'Unload Me
'Exit Sub
GoTo ExitHere
Resume Next
I checked the record set and it returns records. however I can't get to display the resuts in the sub form.
The fields in the sub form show up as #name?
What Am I doing wrong??
I have attached an image.
Thanks in advance.
EG