J
Jade5
Hello:
I have 3 tables - corporation, institution, institution type. 1 to many
relationship between corporation and institution and institution and
institution type. I can enter the insitution number in a combo box and do a
search based on the insitution number which opens the corporation form which
displays all three tables. How can I enter a type id and have the corporation
form open in the same way. Here is the code that works for the insitution
number. BTW the Institution search combo box has 2 fields institution ID and
corporation ID. The type search combo box has 3 fields - the type id, the
institution id and the corporation id.
Dim rs As DAO.Recordset
Dim strWhere As String
If Not IsNull(Me.Combo3) Then
strWhere = "[Corporation ID] = """ & Me.Combo3.Column(1) & """"
DoCmd.OpenForm "Corporation", WhereCondition:=strWhere
If Forms("Corporation").NewRecord Then
MsgBox "Corporation not found."
Else
strWhere = "[Institution ID] = """ & Me.Combo3 & """"
With Forms("Corporation")![Institution].Form
Set rs = .RecordsetClone
rs.FindFirst strWhere
If rs.NoMatch Then
MsgBox "Site not found"
Else
.Bookmark = rs.Bookmark
End If
End With
End If
End If
Thanks,
J
I have 3 tables - corporation, institution, institution type. 1 to many
relationship between corporation and institution and institution and
institution type. I can enter the insitution number in a combo box and do a
search based on the insitution number which opens the corporation form which
displays all three tables. How can I enter a type id and have the corporation
form open in the same way. Here is the code that works for the insitution
number. BTW the Institution search combo box has 2 fields institution ID and
corporation ID. The type search combo box has 3 fields - the type id, the
institution id and the corporation id.
Dim rs As DAO.Recordset
Dim strWhere As String
If Not IsNull(Me.Combo3) Then
strWhere = "[Corporation ID] = """ & Me.Combo3.Column(1) & """"
DoCmd.OpenForm "Corporation", WhereCondition:=strWhere
If Forms("Corporation").NewRecord Then
MsgBox "Corporation not found."
Else
strWhere = "[Institution ID] = """ & Me.Combo3 & """"
With Forms("Corporation")![Institution].Form
Set rs = .RecordsetClone
rs.FindFirst strWhere
If rs.NoMatch Then
MsgBox "Site not found"
Else
.Bookmark = rs.Bookmark
End If
End With
End If
End If
Thanks,
J