Objective said:
linking the second form to the record in the first form
Filter = / Filter On is one approach. Works fine when openning a form, or when applying a filter.
Have you tried using the wizard for the combo box with the open form thread? One thread allows you to open the target form and find a specific record target record that matches a key from the source form -- sounds like something you are doing. The nice thing here is that the wizard does most of the work for you.
Another approach. You can actually use the
OnCurrent event procedure so that if the source form is open, as you scroll through the source records, the records on the target form are synchronized.
Coding is not too difficult. This is one approach for this strategy...
- FormA, source form
- Contact, target form
- EMPI - is a text string, and is the name of text boxes on both form FormA and form Contact, and the corresponding field has the same name
- tblContact, source for Contact form
Code:
Dim strSQL as String, strQ as String
Dim Frm as Form, strForm as String
Dim booPass as Boolean
strQ = Chr$(34)
booPass = False
strForm = "Contact"
For Each Frm in forms
If Frm.Name = strForm Then
booPass = True
End If
Next Frm
If booPass Then
strSQL = "SELECT * From tblContact WHERE EMPI = " _
& strQ & Me.EMPI & strQ
Set Frm = Forms!strForm
Frm!Recordsource = strSQL
Frm.Requery
End If
If the EMPI field is numeric, then ...
strSQL = "SELECT * From tblContact WHERE EMPI = " & Me.EMPI
If the target form is not open, nothing happens. If the target form is open, then the displayed record in
Contact[\i] will change to the corresponding record change in TableA[\i].
There are other stratagies...
Richard