• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 377
  • Last Modified:

Adding data into a combo box in ACCESS from ACCESS datasbase

I have a database in access and some forms.

I need to load the data from my SQL query into my combo box

I am using DAO connection.

This is the code I have so far

Private Sub UserForm_Activate()

LabelTitle.Caption = "Please Choose The Foreman For The Day"
Button_Approve.Caption = "Approve Timesheet"
Button_Edit.Caption = "Edit Timesheet"

Dim wspace As DAO.Workspace
Dim db As DAO.Database
Dim rs1 As Recordset
Dim Query2 As String
Dim timesheet As String
'timesheet = Globals.timesheetidtoapprove
timesheet = "'020320081031'"

Set wspace = DBEngine.Workspaces(0)
Set db = wspace.OpenDatabase(Globals.Databaselocation)

Query2 = "Select Timesheet_Date.ForemanID From Timesheet_Date Where Timesheet_Date.TimesheetID = " & timesheet & ";"
Set rs1 = db.OpenRecordset(Query2)

timesheet = (rs1("ForemanID").Value)

'' This is where I am getting an error - No record Found
ComboBox_Foreman.AddItem (rs1("ForemanID").Value)


Open in new window

This is the structure of the table timesheet_date

TimesheetID SuperintendentID ForemanID TimesheetDate Approval
1 Solution
Bill RossCommented:

VBA programming is not needed for this...


Create a query with the info that you want shown and test.
Open the form in design view and select Properties of the desired Combo Box.
Select the query as the Row Source for the combo box.


Trying_to_LearnAuthor Commented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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