P
PC User
I have been making use of the concept of subform swapping from a
Subform Swapping Demo; however, now I've come across a problem of
syncronizing the subforms. I've been able to use a filter combobox on
the main form and control the results in the subforms by changing the
RecordSource. However, now when I flip from one subform to the next, I
need the next appearing subform to show the same record (or Primary
Key [PK]) that was on the previous subform and still be able to
navigate through the entire recordset if I choose. So I thought that
using bookmarks would be the answer.
I'm using the PK (PersonID) which is an Autonumber field with a "Long"
property in a global variable "Public gintPersonID As Long". I've been
trying to use a public function bookmark code in that I'm thinking
that I can match the PK of the table's recordset with the PK of the
subform's recordclone. Is this something that can be done? Currently
the problem is that I'm getting an error "Error #13: Type Mismatch".
===============================
Public Function FormSync()
On Error GoTo Whoops
Dim rs As DAO.Recordset, frs As DAO.Recordset
Dim frm As Form, sfrm As Form
Dim intCriteria As Integer
Dim db As DAO.Database
Set frm = Forms!frmMain
Set sfrm = frm!ctlGenericSubform.Form
Set frs = sfrm.RecordsetClone
Set db = CurrentDb()
Set rs = db.OpenRecordset("tblPeople", dbOpenDynaset)
intCriteria = "[PersonID] = " & gintPersonID
If IsNull(gintPersonID) Then
MsgBox "No PersonID found"
Else
rs.FindFirst intCriteria
frs.Bookmark = rs.Bookmark
End If
rs.Close
frs.Close
db.Close
OffRamp:
Exit Function
Whoops:
MsgBox "Error #" & Err & ": " & Err.Description
Resume OffRamp
End Function
===============================
Thanks,
PC
Subform Swapping Demo; however, now I've come across a problem of
syncronizing the subforms. I've been able to use a filter combobox on
the main form and control the results in the subforms by changing the
RecordSource. However, now when I flip from one subform to the next, I
need the next appearing subform to show the same record (or Primary
Key [PK]) that was on the previous subform and still be able to
navigate through the entire recordset if I choose. So I thought that
using bookmarks would be the answer.
I'm using the PK (PersonID) which is an Autonumber field with a "Long"
property in a global variable "Public gintPersonID As Long". I've been
trying to use a public function bookmark code in that I'm thinking
that I can match the PK of the table's recordset with the PK of the
subform's recordclone. Is this something that can be done? Currently
the problem is that I'm getting an error "Error #13: Type Mismatch".
===============================
Public Function FormSync()
On Error GoTo Whoops
Dim rs As DAO.Recordset, frs As DAO.Recordset
Dim frm As Form, sfrm As Form
Dim intCriteria As Integer
Dim db As DAO.Database
Set frm = Forms!frmMain
Set sfrm = frm!ctlGenericSubform.Form
Set frs = sfrm.RecordsetClone
Set db = CurrentDb()
Set rs = db.OpenRecordset("tblPeople", dbOpenDynaset)
intCriteria = "[PersonID] = " & gintPersonID
If IsNull(gintPersonID) Then
MsgBox "No PersonID found"
Else
rs.FindFirst intCriteria
frs.Bookmark = rs.Bookmark
End If
rs.Close
frs.Close
db.Close
OffRamp:
Exit Function
Whoops:
MsgBox "Error #" & Err & ": " & Err.Description
Resume OffRamp
End Function
===============================
Thanks,
PC