Listbox Code

PC User

Registered User.
Local time
Today, 11:40
Joined
Jul 28, 2002
Messages
193
I have a form "frmMAINEntry" with a tabcontrol with several pages. The form's Record Source is a query "qryMainData"; however, on two of the pages there's a difference. On the page "Program List" I have a listbox that has a Row Source to table "tsubProgramList" and on the page "Program Details" I have a subform that's Record Source is also "tsubProgramList". The two pages of the tabcontrol are: "ctlProgramDetails" and "ctlProgramList".

The table tsubProgramList contains these fields:
ProgramID..............AutoNumber
Program Description...Text
Facility...................Text
ProgramCoordinator...Text

I'm trying to develop code that will allow me to doubleclick on an item in the listbox which will change tab pages and display the selected record in the subform that's on the other tab page. See code below:

Code:
=================================================
Private Sub lstPrograms_DblClick(Cancel As Integer)
Dim rs As Object
Dim db As Database
Set db = CurrentDb()
Set rs = Forms![frmMainEntry]![fctlProgramList].Form.Recordset.Clone
rs.FindFirst "[ProgramID]" = " & Str(Nz(Me![lstPrograms], 0))"
If Not rs.EOF Then Forms![frmMainEntry]![fctlProgramList].Form.Bookmark = rs.Bookmark
Me![ctlProgramDetails].SetFocus
Call HideNavButtons
End Sub

=================================================
Someone's help would be greatly appreciated.

PC
 
What do you have in the Master and Child Relations fields in the sub-form on ctlProgramDetails?
 
That's a good point. Maybe I should link them by the [ProgramID] field?
 
Thank you for your suggestion; however the record source for listbox and the subform are different from the record source for the mainform; so the Master/Child links are not compatable. I need to make a link between the listbox and the subform, not between the mainform and the subform.
 

Users who are viewing this thread

Back
Top Bottom