Mackin, Christopher
CMackin at quiznos.com
Fri Dec 10 13:59:19 CST 2004
Try the Load Event instead and add a Requery after setting the RowSource:
Private Sub Form_Load()
If Forms!frmProjects!Text55 = "open" Then
Me.List52.RowSource = "qryFindOpenProjects"
Else
Me.List52.RowSource = "qryFindAllProjects"
End If
Me.List52.Requery
End Sub
Also, looking a little closer at the code you have, make sure that the value returned by Forms!frmProjects!Text55 is what you're expecting. If "open" or "all" is not in Text55 {here's where a naming convention would be useful} then your code would not set the RowSource.
-Chris Mackin
-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Klos, Susan
Sent: Friday, December 10, 2004 12:58 PM
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