Link to home
Start Free TrialLog in
Avatar of ChuckRush
ChuckRush

asked on

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?

Thanks
Avatar of DavidT543
DavidT543
Flag of United Kingdom of Great Britain and Northern Ireland image

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()
	LoadStaffNames
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 '*
		myDropDown1.additem(myItemtoAdd)

	Next
	set oControls = nothing
End Sub

Open in new window

Avatar of ChuckRush
ChuckRush

ASKER

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:
www.outlookcode.com
Lost of info and samples there.

Microsoft supplied their own 2 part introduction.
Prt 1 is here:
http://msdn.microsoft.com/en-us/library/aa155722(v=office.10).aspx
Its would be well worth reading both parts.

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?

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.
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.

www.davton.com/downloads/DavtonOpportunityTracker.pst

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 .
ASKER CERTIFIED SOLUTION
Avatar of DavidT543
DavidT543
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
Thanks -- this have given me the jump start i needed.