Solved

MS Access 2007 - Programatically select value in combobox

Posted on 2013-05-11
8
17 Views
Last Modified: 2016-07-24
I am populating a form and I need to programatically select a value in a combobox.

I tried me.mycombobox.value = i

Its not working.

Any idea how to do this?

Thanks
0
Comment
Question by:CipherIS
  • 5
  • 2
8 Comments
 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
what is the rowsource of the combo box?

post the rowsource of your combo box.

is your form bound to a table or query or unbound?
0
 
LVL 1

Author Comment

by:CipherIS
Comment Utility
Here is how the combobox is being populated.

Private Sub GetLocations()

    Dim db As Database
    Dim rs As Recordset
    Dim i As Integer
    
    i = 0
    
    sql = "SELECT LocationID, LocationType, LocationName, ProjectID "
    sql = sql & "FROM Location "
    sql = sql & "WHERE ProjectID = " & Me.cboProjectID.Column(0) & " "

    Set db = CurrentDb
    Set rs = db.OpenRecordset(sql)

    Me.cboLocation.RowSource = ""

    If Not rs.EOF Then
        Me.cboLocation.Locked = False
        Do Until rs.EOF
            Me.cboLocation.AddItem Item:=rs![LocationID] & ";" & rs![LocationName] & ";" & rs![LocationType], Index:=i
            rs.MoveNext
            i = i + 1
        Loop
    End If
    
    rs.Close

End Sub

Open in new window

0
 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
what about your form, can you provide a description about your form?

can you give more explanation on

< i need to  programatically select a value in a combobox. >

based on what?, which item in the combo box do you want to be selected programmatically ?
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 1

Author Comment

by:CipherIS
Comment Utility
I figured it out.  Thanks for the help.
0
 
LVL 1

Author Comment

by:CipherIS
Comment Utility
I've requested that this question be closed as follows:

Accepted answer: 0 points for CipherIS's comment #a39158637

for the following reason:

figured it out
0
 
LVL 1

Accepted Solution

by:
CipherIS earned 0 total points
Comment Utility
me.mycombobox.value = i was the solution.  There was an issue with the combobox.
0
 
LVL 1

Author Closing Comment

by:CipherIS
Comment Utility
Resolved the issue
0

Featured Post

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

763 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

7 Experts available now in Live!

Get 1:1 Help Now