Hi all,
I’m hoping someone can help me out … I am a programmer, but have little experience with Access programming. I am working on an Access project (linking to SQL Server 7) to maintain a book database. The particular form I have a problem withis based on 3 tables:
Title (key ISBN)
GroupTitle (key field GroupISBN)
GroupLinkISBN (fields ISBN, GroupISBN)
and serves to link titles into groups using ISBNs.
I have a main form based on the Title table with a subform, linked via a key field (ISBN). The subform is a continuous form using GroupLinkISBN as a record source. It contains a single visible field, selectable using a combo box, which pulls up records from GroupTitle so that the title in the main form can be added to one or more groups. The two forms are linked using the ISBN field. This works very well, allowing users to select values from the GroupTitle table, and insert matching records into GroupLinkISBN. But now I want to use different tables as the record source for the subform and combo box, depending on the value of a field in the main form. I have half got this working using the following code for the subform:
Private Sub frmselTitleMulti_Enter()
If Me.PPCFlag = “P” Then
strSQL = “SELECT ISBN, GroupTitle FROM PPGroupTitle ORDER BY GroupTitle”
Me.frmselTitleMulti.Form.RecordSource = “PPGroupLinkISBN”
Else
strSQL = “SELECT ISBN, MultiTitle FROM GroupTitle ORDER BY GroupTitle”
Me.frmselTitleMulti.Form.RecordSource = “GroupLinkISBN”
End If
‘ combo box source
Me.frmselTitleMulti!Multibuy.RowSource = strSQL
End Sub
The combo box is being populated with values from the correct table, depending on whether the PPCFlag field is P or not. And if I select a value and save the record, it is inserted to the PPGroupLinkISBN or GroupLinkISBN table as it should be. My problem is that if I close the form and return to it, if there is a P in the PPCFlag field the subform is not populated with existing records from the PPGroupTitleISBN title as it should be — although it still works fine for “non-P” titles. Can anyone tell this Access newbie what I am missing??
Hope I’ve made this clear — it was difficult to explain!
Thanks