Outlook Form VB

I am starting my first custom Outlook form design. It contains several ComboBoxes that i will need to fill from MySql tables. I think i have all of the code required to access the DB properly from VB but i can seem to get the VB to to execute when i run the form. Can someone please point me in the right direction?

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Make sure you put the code in the 'open' event of the form.

I've given an edited example of some code from one of my working forms.
THis works fine for drop downs.

It used to get screwed up for list boxes if you added items after the form loaded (the items got double spaced). Not sure if MS ever fixed that.
Function Item_open()
End Function

Sub LoadStaffNames
	'* 'Tasks' is the name of the tab on which your form controls are placed - e.g 'General, P.1 etc 
	Set oControls=Item.GetInspector.ModifiedFormPages("Tasks").Controls
	set myDropDown1 = oControls("cmbNames1")
	For I = 1 to numEntries
		myItemtoAdd = '* some code to get your data value '*

	set oControls = nothing
End Sub

Open in new window

ChuckRushAuthor Commented:
Good Morning   thanks for getting back to me. I have similar code in the Item_Open routine. Perhaps i need to know where an explanation of the Object types and available events can be found. I have ordered several books but if you know of a link that would help.

First of all if i am in design mode and i choose to 'Run this form' the code never fires. If i select macros and choose the code it does execute. I am sure i am missing some thing basic here. I have been an access developer for a long time and i guess that model is not the same. When i step into the line that starts OControls =  i get an error looking for an object and i think i need to define OControls as a type.

Any other pointers?
Hi ChuckRush,

OK - the best book is by Sue Mosher - Microsoft Outlook Programming 2007
She used to run a web site where all these kinds of issues were discussed:
Lost of info and samples there.

Microsoft supplied their own 2 part introduction.
Prt 1 is here:
Its would be well worth reading both parts.

Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

If you put a.....

    msgbox "Hello"

....statement as the first and only line of your Item_open() function - does that fire?
If not its a permissions type thing, if it does its a bug in your code!

With custom forms, you need to publish them to the folder you want to use them in(although it should work to test them by just using the 'run this form' option from developer mode).

What type of form is it?

ChuckRushAuthor Commented:
Ok Thanks -- I did order the first book. the Msgbox does not display. I used a Journal entry to start with and added a couple of Comboboxes to the 2nd page. If i go from design mode to 'Run this Form' it displays my form but does not display the code. I published it and it also did not fire the code.
ChuckRushAuthor Commented:
OK I found part of my problem. I was putting code into the Visual Basic editor instead of the script editor. When i put a msgbox there it does display. I am still trying to figure out how to call a VB routine from the script editor. It looks as if script does not have a debug mode -- again what am i missing here.
Script is as basic an editor as you will find.

I debug forms using msg boxes - displaying values of key information.

It might help to have an example working form to start from.

I have a sales opportunity management form based on a task form in a pst file you can download.
It has been on my web site for several years, but it might point you on the right direction.


Save the pst file to your file system, and then open from outlook by selecting open outlook data file and navigate to the location you saved the pst file.

I don't think it has any combos loading items, but the code from my first post shows you how to do that. You just need to get the correct name of the tab which the controls are on .
You need to put all your form code in the form. VB routines included (they will need to be vbscript routines)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ChuckRushAuthor Commented:
Thanks i am sure this will help but the pst does nothave the referenced folder
The folder is there because I tested it before I posted the comment.

Its is a task folder, so the navigation pane will need to be showing tasks, or folder list for you to see it.
ChuckRushAuthor Commented:
Thanks -- this have given me the jump start i needed.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Applications

From novice to tech pro — start learning today.

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.