Populating a listbox from a combo

Access_Help

Registered User.
Local time
Yesterday, 20:27
Joined
Feb 12, 2005
Messages
136
OK, so I'm not sure where the error is in this VBA script applied to the after update property of the combobox:

Code:
Option Compare Database
Private Sub Combo6_AfterUpdate()
Dim SQL As String
SQL = "Select * From [qry_email_addresses] where [Post_Code] = " & Me![Combo6]
Me![List2].RowSource = SQL
Me![List2].Requery
End Sub

When I run it, it is breaking up the postcode values in the combobox and prompting them seprately as 'enter parameter value'?
 
Assuming the Postcode is Text then you need to enclose it in quotes ;

Code:
SQL = "Select * From [qry_email_addresses] where [Post_Code] =[COLOR="red"] '[/COLOR]" & Me.Combo6 & [COLOR="Red"]"'"[/COLOR]
 
Me![List2].Requery is superfluous - setting the RowSource effectively does that implicitly.

hth,

d
 

Users who are viewing this thread

Back
Top Bottom