[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 174
  • Last Modified:

Preselecting a value in a combo box

Hello,

I'm wondering if anyone can help me preselect a valuie in a combo box?  With the code below, I'm populating m combo as shown as in my jpg.  Now, how do I preselect V3 (2nd item)

After the code, I tried cboPaymLocs.ListIndex = 1 but I get '7777' - You've used the litstindex property incorrectly.

Any help is greatly appreciated.
strSQL = "SELECT * FROM [tblVehicles] " & _
             "WHERE (fldArchived = False) " & _
             "ORDER BY fldVehNo;"
             
    With CurrentDb.OpenRecordset(strSQL)
        If .RecordCount > 0 Then
            .MoveFirst
            Do While Not .EOF
                    
                strName = "Vehicle: " & .Fields("fldVehNo")
                cboPaymLocs.AddItem "V" & .Fields("fldVehID") & ";" & strName
                .MoveNext
            Loop
        End If
    End With
    
    strSQL = "SELECT * FROM [tblLocations] " & _
             "WHERE (fldArchived = False) " & _
             "ORDER BY fldLocID;"
             
    With CurrentDb.OpenRecordset(strSQL)
        If .RecordCount > 0 Then
            .MoveFirst
            Do While Not .EOF
                    
                strName = "Location: " & .Fields("fldLocation")
                cboPaymLocs.AddItem "L" & .Fields("fldLocID") & ";" & strName
                .MoveNext
            Loop
        End If
    End With

Open in new window

Picture1.jpg
0
APD Toronto
Asked:
APD Toronto
1 Solution
 
bromy2004Commented:
Try cboPaymLocs.Value=cboPaymLocs.ListIndex(1)
0
 
APD TorontoAuthor Commented:
At the list indexd, I get
Wrong number of arguments or invalid property assignment.
0
 
Rey Obrero (Capricorn1)Commented:


cboPaymLocs.value=cboPaymLocs.itemdata(1)
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now