Page 1
Page 2
Add a label and combobox to the form as shown

making sure to change the Style of the combobox
to a dropdownlist box. The last step is to add the code.
Add the following to the code to the form declaration:
Public conndb As ADOCE.Connection
Sub LoadCtrl(paramCtrl As ComboBox, paramSQL As
String)
Dim rsCtrl As ADOCE.Recordset
Dim val1 As Integer
Dim val2 As String
Set rsCtrl = CreateObject("ADOCE.RecordSet.3.0")
rsCtrl.Open paramSQL, conndb, adOpenForwardOnly, adLockReadOnly
If rsCtrl.RecordCount > 0 Then
Do While Not rsCtrl.EOF
If IsNumeric(Trim(rsCtrl.Fields(0))) Then _
val1 = CInt(rsCtrl.Fields(0))
val2 = rsCtrl.Fields(1)
paramCtrl.AddItem val2
paramCtrl.ItemData(paramCtrl.NewIndex) = val1
rsCtrl.MoveNext
Loop
End If
rsCtrl.Close
Set rsCtrl = Nothing
End Sub
Add the following code to the form load event:
Private Sub Form_Load()
'Connect to the database
Set conndb = CreateObject("ADOCE.Connection.3.0")
conndb.ConnectionString = "data source = \My Documents\Northwind.cdb"
conndb.Open
Call LoadCtrl(Form1.cmbCustomers, "select customerid, companyname
from customers")
conndb.Close
Set conndb = Nothing
End Sub
Take care when you copy and paste to make sure
that the lines do not wrap as they have in HTML - they need to
be one line in the editor.
Now press F5 and you should see the data in
the list box.

If you have a problem connecting
to the database, getting the dialog box below then go back to the tutorial
on Transferring
data onto your Pocket PC and make sure to note the CDB location on
your Pocket PC when "importing" the data. You can also use the
ActiveSync Explorer to double check the location of the .cdb file.
Previous Page