Solved

Adding data into a combo box in ACCESS from ACCESS datasbase

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

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…
Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
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…
Familiarize people with the process of utilizing SQL Server functions 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 Ac…

706 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