Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

trying to populate a single combo box with distinct values 1

Status
Not open for further replies.

miscluce

MIS
Oct 4, 2007
149
US
I have a form with a combo box (cboMake) on it. I have a table(tblCar).
I am trying to populate distinct values into a combo box and access is not working like SQL?

I thought his would work but I guees not. Can someone tell me what I am doing wrong? I am getting a object variable or with variable not set error.

my code:

Private Sub Form_Load()

Me.cboMake.Recordset = "SELECT DISTINCT * FROM tblCar"

End Sub
 
Also, when I use the sql/query in Access and put DIstinct under the criteria and that returns no results??
 
use

Me.cboMake.RowSource = "SELECT DISTINCT * FROM tblCar"


instead
 
also, i think you need to specify the actual field when using "Distinct." i'm not sure about that though.
 
thanks. thats is right, its rowsource. I missed that.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top