Solved

Adding data into a combo box in ACCESS from ACCESS datasbase

Posted on 2012-03-25
2
364 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

895 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now