[AccessD] Setting the row source of a listbox by code

Jim Lawrence (AccessD) accessd at shaw.ca
Fri Dec 10 15:46:01 CST 2004


Hi Susan:

Just a quick note; maybe the listboxes should be initialized/filled in the
Form_Load event instead of the Form_Open event as the listbox objects may
not exist until the Form_Load event.

HTH
Jim

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Klos, Susan
Sent: Friday, December 10, 2004 11:58 AM
To: 'AccessD at databaseadvisors.com'
Subject: [AccessD] Setting the row source of a listbox by code


I have narrowed my problem to this:  I have a listbox and two queries.  If
the form is opened where txtfindProjects = "open", I want to set the row
source of the listbox to qryFindOpenProjects.  Otherwise I want the row
source of the listbox to be qryFindAllProjects.  Here is my code which I
have tried in several events and it doesn't seem to work in any of them.

Private Sub Form_Open(Cancel As Integer)



DoCmd.Maximize

If Forms!frmProjects!Text55 = "all" Then

Me.List52.RowSource = "qryFindAllProjects"

ElseIf Forms!frmProjects!Text55 = "open" Then

Me.List52.RowSource = "qryFindOpenProjects"





End Sub



Any ideas?  Thanks.



Susan Klos

Senior Database Analyst

Evaluation and Reporting

Florida Department of Education

850-245-0708

sc 205-0708



--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com




More information about the AccessD mailing list