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?

Thanks
LVL 1
CipherISAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
CipherISConnect With a Mentor Author Commented:
me.mycombobox.value = i was the solution.  There was an issue with the combobox.
0
 
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?
0
 
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
            rs.MoveNext
            i = i + 1
        Loop
    End If
    
    rs.Close

End Sub

Open in new window

0
Easily Design & Build Your Next Website

Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.

 
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 ?
0
 
CipherISAuthor Commented:
I figured it out.  Thanks for the help.
0
 
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
0
 
CipherISAuthor Commented:
Resolved the issue
0
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.