Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Listbox Code

Status
Not open for further replies.

pcgenie

Technical User
Dec 11, 2003
15
US
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

 
Replace this:
rs.FindFirst "[ProgramID]" = " & Str(Nz(Me![lstPrograms], 0))"
By this:
rs.FindFirst "[ProgramID]=" & Nz(Me![lstPrograms], 0)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top