-
Subform to Subform Problemo.
Hi,
I'm only a beginner with Access and VBA (on a windows platform - Access 2000) etc so apologies up front.
I have a main form (called frmMAININTERFACE), within which I've inserted a tab control item. Each page in the tab control thing is going to contain a subform, each subform relating to a different table. This means (as far as I know) that the overall main containing form cant be based upon a table (or at least, not inasmuch as it will have any effect on what I'm trying to achieve).
Here is the problem I have. On one of the tab pages within the main form, I have a subform down the left. This is a continuous form displaying only the CompanyName field from the Companies table - just a list really. I'll call this subform LISTSUB. Then, to the right of this subform, I have another subform, containing the entire set of fields from the Companies table (this second subform is called frmCOMPANYDETSUB). Each company name within LISTSUB is set up as a hyperlink, and I want to set this up with an OnCurrent event to synch the records in the frmCOMPANYDETSUB subform to whatever Company name I click on in LISTSUB.
On a previous version of this database, I set this up so that the parent form is driven from the Companies table, and contains all of the details field (phone, address, email etc) for the companies - the LISTSUB form is embedded within the parent form, and it synchs in a very straightforward manner. But because each aspect of the form in this version sits within a tabbed page item, I can't do it the way I did before. In this version, I'm trying to control subform two from subform one and I'm a little puzzled as to the syntax of how to do it.
This is what I've got so far - it can't suss out what it's supposed to be referencing...
___________________________________________
If IsNull(Me.CompanyName) Then
Exit Sub
End If
Dim formname As Form, SyncCriteria As String
Dim F As Form, rs As Object
Set formname = Forms![frmBABYMAININTERFACE]![frmCOMPANYDETSUB].Form
'the bit above is the bit it keeps highlighting as the error
Set F = Forms(formname)
Set rs = F.Recordset.Clone
If InStr(1, Me.CompanyName, "'") > 0 Then
SyncCriteria = "[CompanyName] =" & Chr(34) & Me!CompanyName & Chr(34)
Else
SyncCriteria = "[CompanyName] ='" & Me!CompanyName & "'"
End If
rs.FindFirst SyncCriteria
If rs.EOF Then
MsgBox "No match exists!", 64, formname
Else
F.Bookmark = rs.Bookmark
End If
_____________________________________________
I haven't looked at the actual synching bit yet, coz I haven't yet figured out how to get the 2 to reference each other. Using the code above, it highlights the Setform line, and chucks up the error "Microsoft Access can't find the field 'frmCOMPANYDETSUB' referred to in your expression" so I guess that syntax is the wrong syntax to use.
I don't know whether to use some kind of Parent syntax, or whether to reference the second form via the control name (which is Child6 by the way)
I hope this all makes sense. Can anyone give me any clues as to how I should go about this? It would be *greatly* appreciated.
Thanks.
Edward.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|