Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combobox conversion from VB or how to pass the excel object to VB

Status
Not open for further replies.

msl1

Programmer
Mar 5, 2003
5
US
Hi, Currently I am having an issue with vb to vba conversion, since there are no itemdata properties or anything like that. I need to have underlying values for my combobox to insert into a database, but also be able to call application.calculatefull after the insertion for various UDFs on the spreadsheet. The code I am trying to conver is here
Code:
Private Sub Form_Load()
 Dim db As Connection
   Set db = New Connection
   db.CursorLocation = adUseClient
   db.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=C:\tradeview\Tradelog.mdb;"

   Set adoPrimaryRS = New Recordset
   adoPrimaryRS.Open "select futsymbol, ID from futuresdata", db, adOpenStatic, adLockOptimistic
    
   varrecords = adoPrimaryRS.GetRows(adoPrimaryRS.RecordCount)
   For x = 0 To adoPrimaryRS.RecordCount - 1
   If varrecords(0, x) <> &quot;&quot; Then CommBox.List(x) = varrecords(0, x)
   If varrecords(1, x) <> &quot;&quot; Then CommBox.ItemData(x) = varrecords(1, x)
   Next x
   Set adoPrimaryRS = Nothing
   
   Set adoPrimaryRS = New Recordset
   
   adoPrimaryRS.Open &quot;select Name, ID from system order by name&quot;, db, adOpenStatic, adLockOptimistic
   varrecords = adoPrimaryRS.GetRows(adoPrimaryRS.RecordCount)
   
   For x = 0 To adoPrimaryRS.RecordCount - 1

   If varrecords(0, x) <> &quot;&quot; Then
        SystemBox.List(x) = varrecords(0, x)
        If varrecords(1, x) <> &quot;&quot; Then SystemBox.ItemData(x) = varrecords(1, x)
   End If
   Next x
   Set adoPrimaryRS = Nothing
   
   Set adoPrimaryRS = New Recordset
   adoPrimaryRS.Open &quot;select AccountName, AccountNO from accounts&quot;, db, adOpenStatic, adLockOptimistic
   If adoPrimaryRS.RecordCount > 0 Then varrecords = adoPrimaryRS.GetRows(adoPrimaryRS.RecordCount)
    
   For x = 0 To adoPrimaryRS.RecordCount - 1

   If varrecords(0, x) <> &quot;&quot; Then AccountBox.List(x) = varrecords(0, x)
   
   If varrecords(1, x) <> &quot;&quot; Then AccountBox.ItemData(x) = varrecords(1, x)
      
   Next x
   Set adoPrimaryRS = Nothing
   
End Sub

this is just to load my order entry screen, but I cannot figure out how to do underlying values in comboboxes in vba. Like I said before, if I can just pass the excel object to VB, I should be able to do it from there. Anyone have any ideas?

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top