Background: I have a Form/subform, it is loosely modeled after Allen Browne's Search form. The search function performs flawlessly, Both queries are localized to the subform (ie. not a named query), and both run without error. The problem I am having is one of the subforms only shows one record. I'm stumped.
Mainform: The section in question has a dropdown box called cboType. In this combo box a user selects 1 of 2 subforms to search (subform is in unbounded "subfrm" field), then the appropriate subform populates. 1 of the 2 runs smoothly, sfrm_search-pro should be showing 1500 records, it is only showing the first one.. I have performed the following steps tyring to T/S:
1. Read through many posts, here and across the Google (internet)
2. Run Debug frequently, and the right values are being passed.
3.Compared properties of sfrm_search-rcm & sfrm_searchPro, cannot find any differences. Both are continuous forms.
cboType_AfterUpdate Code:
CODE
Private Sub cboType_AfterUpdate() 'Select the source -- Works
Dim tbl As String 'The table string
Dim strSubform As String 'Subform string
On Error GoTo Err_cboType_AfterUpdate
If Me!cboType.Value = "tbl_rcm" Then
tbl = "tbl_rcm"
'Debug.Print Me!cboType.Value 'T/S: Open immediate window (CTRL+G) to view results.
'Debug.Print tbl 'T/S: Open immediate window (CTRL+G) to view results.
End If
If Me.cboType.Value = "tbl_pro" Then
' MsgBox "Selection not available yet", vbOKOnly, "Invalid Selection" 'T/S: Selection not initiated.
tbl = "tbl_pro"
Debug.Print Me!cboType.Value 'T/S: Open immediate window (CTRL+G) to view results.
End If
Me.RecordSource = tbl
Me.Requery
'Debug.Print "Record source= "; tbl 'T/S: Open immediate window (CTRL+G) to view results.
'Grab proper subform
If Me!cboType.Value = "tbl_rcm" Then
strSubform = "sfrm_search-rcm"
'Debug.Print strSubform
End If
If Me!cboType.Value = "tbl_pro" Then
strSubform = "sfrm_search-pro"
'Debug.Print strSubform
End If
'Load subform
Forms!frm_search![subfrm].SourceObject = strSubform
Me.[subfrm].Form.Requery
Exit_cboType_AfterUpdate:
Exit Sub
Err_cboType_AfterUpdate:
'MsgBox Err.Description
Call LogError(Err.Number, Err.Description, "Search--cboType_AfterUpdate()")
Resume Exit_cboType_AfterUpdate
End Sub
Dim tbl As String 'The table string
Dim strSubform As String 'Subform string
On Error GoTo Err_cboType_AfterUpdate
If Me!cboType.Value = "tbl_rcm" Then
tbl = "tbl_rcm"
'Debug.Print Me!cboType.Value 'T/S: Open immediate window (CTRL+G) to view results.
'Debug.Print tbl 'T/S: Open immediate window (CTRL+G) to view results.
End If
If Me.cboType.Value = "tbl_pro" Then
' MsgBox "Selection not available yet", vbOKOnly, "Invalid Selection" 'T/S: Selection not initiated.
tbl = "tbl_pro"
Debug.Print Me!cboType.Value 'T/S: Open immediate window (CTRL+G) to view results.
End If
Me.RecordSource = tbl
Me.Requery
'Debug.Print "Record source= "; tbl 'T/S: Open immediate window (CTRL+G) to view results.
'Grab proper subform
If Me!cboType.Value = "tbl_rcm" Then
strSubform = "sfrm_search-rcm"
'Debug.Print strSubform
End If
If Me!cboType.Value = "tbl_pro" Then
strSubform = "sfrm_search-pro"
'Debug.Print strSubform
End If
'Load subform
Forms!frm_search![subfrm].SourceObject = strSubform
Me.[subfrm].Form.Requery
Exit_cboType_AfterUpdate:
Exit Sub
Err_cboType_AfterUpdate:
'MsgBox Err.Description
Call LogError(Err.Number, Err.Description, "Search--cboType_AfterUpdate()")
Resume Exit_cboType_AfterUpdate
End Sub
I appreciate any assistance you may provide; I'm stumped!
