Populate a combo box

S

Steffkm

Sorry for opening the umpteenth thread to this topic, but after three
days googling for every keyword imaginable, i didn't get useful
results.
I want:
....To populate a combo box on a Outlook 2K3 form with data from an
Access 2K3 Database using VBA
I have:
.... Working VBA-code that allow me to get my data from Access
.... Working VBS-code, that allow me to populate my combo box
.... No idea how to put these two together in one VBA subroutine

I am familiar with VBA in Acccess, I wouldn't have much problems doing
that task in a form there but with Outlook, I have no clues...
If someone could be so kind and maybe just point me to the correct
objects that have to be used, I would be very grateful!

Greetings,
Stefan
 
S

Sue Mosher [MVP-Outlook]

Are you sure VBA is what you want? The usual approach is to put code to handle any UI tasks like that in the VBScript code behind the form, in the Item_Open event handler. It sounds like all you need to do is adapt your VBA code to the VBScript environment by removing any typed variable declarations, declaring constants as needed, etc.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
S

Steffkm

Thank you for your fast response! The problem is: I simply don't know,
how to adapt my VBA code to VBS!

The code is as follows:
Sub GetData()
Dim db As Database
Dim rs As Recordset
Dim i As Integer

Set db = OpenDatabase("c:\database.mdb")
Set rs = db.OpenRecordset("Query", dbOpenSnapshot)

i = 0
Do Until rs.EOF
Debug.Print rs.Fields("Name")
rs.MoveNext
i = i + 1
Loop
End Sub

If I put this bluntly in my Item_Open() script, I the script throws an
error.

Stefan
 
S

Sue Mosher [MVP-Outlook]

I gave you the basics in my earlier post:

" ... adapt your VBA code to the VBScript environment by removing any typed variable declarations, declaring constants as needed, etc."

A typed variable declaration is like this:

Dim db As Database

You must change it to:

Dim db

dbOpenSnapshot is a constant not intrinsic to VBScript. You must declare it as a constant or replace dbOpenSnapshot with its literal value.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top