Solved

Adding data into a combo box in ACCESS from ACCESS datasbase

Posted on 2012-03-25
2
369 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
T-SQL: Wrong Result 7 38
SQL query joining 6 tables in asp.net 4 29
Outlook mail to Access 8 23
Query Task 8 15
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Familiarize people with the process of utilizing SQL Server stored procedures 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 Micr…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

734 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