MS Access 2007 - Programatically select value in combobox

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?

Who is Participating?
CipherISAuthor Commented:
me.mycombobox.value = i was the solution.  There was an issue with the combobox.
Rey Obrero (Capricorn1)Commented:
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?
CipherISAuthor Commented:
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
            i = i + 1
    End If

End Sub

Open in new window

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Rey Obrero (Capricorn1)Commented:
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 ?
CipherISAuthor Commented:
I figured it out.  Thanks for the help.
CipherISAuthor Commented:
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
CipherISAuthor Commented:
Resolved the issue
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.