subform in a tabbed form won't search

  • Thread starter Thread starter kathrynwoning
  • Start date Start date
K

kathrynwoning

I have a subfom w/ a combo box that searches a list of architects then fills
contact information in text boxes on the form. When I place this in a tabbed
form it does not function correctly. The combo box lists the architects, but
the selected architect's information does not fill the text boxes. Can anyone
tell me what variable I am missing that causes (or allows) this malfunction?
 
on the combo box after update:

Private Sub Combo16_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[archID] = " & Str(Nz(Me![Combo16], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
'Me.archID = Forms![frmBidsTabs]![bidArchitect]
End Sub
 
kathrynwoning said:
on the combo box after update:

Private Sub Combo16_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[archID] = " & Str(Nz(Me![Combo16], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
'Me.archID = Forms![frmBidsTabs]![bidArchitect]
End Sub


I don't think that code can ever work, regardless of
main/sun form or tab. Try something more like:

Private Sub Combo16_AfterUpdate()
' Find the record that matches the control.
With Me.RecordsetClone
.FindFirst "[archID] = " & Nz(Me![Combo16], 0)
If Not .MoMatch Then Me.Bookmark = .Bookmark
End With
End Sub
 
That works in the subform as well, but not in the tabbed form. The address
boxes still do not fill with the selected architect.
 
kathrynwoning said:
That works in the subform as well, but not in the tabbed form. The address
boxes still do not fill with the selected architect.


A tab control has nothing to do with this kind of thing so I
guess we need more specific information about how your
form(s?) and combo box are arranged. E.g. did you move the
combo box to the main form or is it still in the subform?
 
No, it is still in the subform. Shall I move it?

Marshall said:
A tab control has nothing to do with this kind of thing so I
guess we need more specific information about how your
form(s?) and combo box are arranged. E.g. did you move the
combo box to the main form or is it still in the subform?
 
I believe I can copy it all from the subform to the main form and make it
work... I don't know what the disadvantages of that are, however.
No, it is still in the subform. Shall I move it?
[quoted text clipped - 3 lines]
form(s?) and combo box are arranged. E.g. did you move the
combo box to the main form or is it still in the subform?
 
No need to move it. The code I posted only assumes that
both the combo box and the records to search are in all the
same form. Since you said that all this works when you open
this form by itself, I am somewhat baffled about what could
be different when this form is used as a subform.

Unless you changed something when you used it as a subform,
the only thing I can think of is that the subform control's
LinkMaster/Child Fields are set to something inappropriate
or the main form parent record has no child records.

Maybe we should modify the code a little to indicate when
there is no matching records (and verify that the code is
actually executed).

Private Sub Combo16_AfterUpdate()
' Find the record that matches the control.
With Me.RecordsetClone
.FindFirst "[archID] = " & Nz(Me![Combo16], 0)
If Not .MoMatch Then
Me.Bookmark = .Bookmark
Else
Beep
End If
End With
End Sub

Give that a try by typing something weird into the combo
box. It should make a sound. Then double check that it
still fails to find a child record when you select a combo
box entry that is guaranteed to exist in the subform's
record source table/query. It should not beep this time. If
it does beep, then there might be something wrong with the
combo box's BoundColumn, ColumnCount or ??
 
Back
Top