Solved

Adding data into a combo box in ACCESS from ACCESS datasbase

Posted on 2012-03-25
2
367 Views
Last Modified: 2012-03-25
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)


rs1.Close
db.Close

Open in new window


This is the structure of the table timesheet_date

TimesheetID SuperintendentID ForemanID TimesheetDate Approval
0
Comment
Question by:Trying_to_Learn
2 Comments
 
LVL 14

Accepted Solution

by:
Bill Ross earned 500 total points
ID: 37763881
Hi,

VBA programming is not needed for this...

Steps:

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.

Regards,

Bill
0
 

Author Closing Comment

by:Trying_to_Learn
ID: 37763898
Thanks!
0

Featured Post

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question