Listbox Rowsource

D

DS

I have one Listbox where I need to change the content from a command
button. On the first command button I have...

Private Sub Command0_Click()
With Me.List3
.RowSource = "SELECT Menus.MenuID, Menus.MenuName, Menus.Active
" & _
"FROM Menus " & _
"WHERE (((Menus.Active) = -1)) " & _
"ORDER BY Menus.MenuName;"
.ColumnCount = 3
.ColumnWidths = "0 in;1.5 in;0 in"
.Requery
End With
End Sub

This works fine...
On the second Command Button I have...

Private Sub Command1_Click()
With Me.List3
..RowSourceType = "Value List"
..RowSource = "SUNDAY" & ",MONDAY" & ",TUESDAY" & ",WEDNESDAY" &
",THURSDAY" & ",FRIDAY" & ",SATURDAY"
..ColumnCount = 1
..ColumnWidth = 1.5 * 1440
..Requery
End With
End Sub

This doesn't work at all. I see no content in the listbox, also then
when I go back and click on the other command button I see Menu.MenuName
instead of the original content...
Any help appreciated.
Thanks
DS
 
R

Rick Brandt

DS said:
I have one Listbox where I need to change the content from a command
button. On the first command button I have...

Private Sub Command0_Click()
With Me.List3
.RowSource = "SELECT Menus.MenuID, Menus.MenuName,
Menus.Active " & _
"FROM Menus " & _
"WHERE (((Menus.Active) = -1)) " & _
"ORDER BY Menus.MenuName;"
.ColumnCount = 3
.ColumnWidths = "0 in;1.5 in;0 in"
.Requery
End With
End Sub

This works fine...
On the second Command Button I have...

Private Sub Command1_Click()
With Me.List3
.RowSourceType = "Value List"
.RowSource = "SUNDAY" & ",MONDAY" & ",TUESDAY" & ",WEDNESDAY" &
",THURSDAY" & ",FRIDAY" & ",SATURDAY"
.ColumnCount = 1
.ColumnWidth = 1.5 * 1440
.Requery
End With
End Sub

This doesn't work at all. I see no content in the listbox, also then
when I go back and click on the other command button I see
Menu.MenuName instead of the original content...
Any help appreciated.
Thanks
DS

You're dealing with the "strin gwithin a string" issue and I think you need
semicolons betwenn the entries instead of commas. Try...

..RowSource =
"'SUNDAY';'MONDAY';'TUESDAY';'WEDNESDAY';'THURSDAY';'FRIDAY';'SATURDAY'"

I have a single set of double quotes around the whole string and switched to
single quotes for the inner string values.
 
D

DS

Rick said:
You're dealing with the "strin gwithin a string" issue and I think you need
semicolons betwenn the entries instead of commas. Try...

.RowSource =
"'SUNDAY';'MONDAY';'TUESDAY';'WEDNESDAY';'THURSDAY';'FRIDAY';'SATURDAY'"

I have a single set of double quotes around the whole string and switched to
single quotes for the inner string values.
Thanks Rick, I just figured the problem out...it's
"Sunday,Monday,Tuesday"
As for the other problem I had to change the rowsourcetype everytime the
command button was clicked otherwise it retained the previous value.
Thanks once again
DS
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top