pass listbox value to query (1 Viewer)

megatronixs

Registered User.
Local time
Today, 13:40
Joined
Aug 17, 2012
Messages
719
Hi all,

I just got stuck with the following. I have a listbox where I have some values. I want to use the value of the first listbox to pass this to a query. I have the below code:
Code:
Private Sub List28_GotFocus()
' Limit the subject emails in the list box
Me.List28.RowSource = "SELECT [Subject] " & "FROM tbl_eMail_Archive " & " WHERE [FolderName] " & "Me.List23.Value"
' Refresh the list box
Me.List28.Requery
End Sub
any ideas why it is not working?

Greetings.
 

pr2-eugin

Super Moderator
Local time
Today, 12:40
Joined
Nov 30, 2011
Messages
8,498
Your concatenation is a bit off.. Try
Code:
Private Sub List28_GotFocus()
    [COLOR=Green]'Limit the subject emails in the list box[/COLOR]
    Me.List28.RowSource = "SELECT [Subject] FROM tbl_eMail_Archive WHERE [FolderName] = '" & Me.List23 & "'"
    
   [COLOR=Green] 'Refresh the list box[/COLOR]
    Me.List28.Requery
End Sub
 

megatronixs

Registered User.
Local time
Today, 13:40
Joined
Aug 17, 2012
Messages
719
Hi,

Big thanks. It is working now :)

Greetings
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top Bottom