[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1815
  • Last Modified:

Populate Access Combo Box from SQL Query

I'm trying to do the following:

Enter your name
Enter you password
[submit]

After submission with button and authentication, populate the appropriate data based off a query on the person's name into a combo box. Any thoughts on how to do this?  I'm writing the function/macros with VB through Access.

I'll usually do something like this:

Dim rselect As New ADODB.Recordset
' open connection stuff here
rselect.Open "select data where name = name", cnn, adOpenStatic, adLockOptimistic

Can I push this rselect set into the combo box or is there a better way to do it?

0
Ant_Dogg
Asked:
Ant_Dogg
  • 2
  • 2
1 Solution
 
peter57rCommented:
Can you clarify what you are using for your forms and  code.

Are you writing a VB front-end with an Access backend or do you mean you are writing vba code in an Access front-end (also with an Access backend)
0
 
Ant_DoggAuthor Commented:
It's Access forms with a SQL server backend.  The behavior of all my buttons are controlled with VB code through Access, such as connection, submissions, and updates to the database.

I want this button to query the SQL database, return a recordset (1 column) and populate it to a combo box.
0
 
peter57rCommented:
You just set the rowsource of the combo to the sql string that you are currently using for your recordset.
Forms!formname!comboname.rowsource = strSQL

I'm assuming your real sql is correctly structured, as the code you posted is not.
0
 
Ant_DoggAuthor Commented:
Thats what I was looking for, thanks!
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now