Dang you VBA!

MrMitch

Registered User.
Local time
Today, 06:03
Joined
Oct 19, 2007
Messages
50
I'm sure this is easy for people that are familiar with VBA, but being the noob that I am. I need a little help trying to write this.

I have a button on a form I need to do a few things.

The first thing I need it to do is simply save the record.

Then I would like it to look at one of my combo boxes and determine what was selected. For example "UP-02", UP-03", etc, and then use "followhyperlink" to the location of the appropriate selection. Example would be "FollowHyperlink "file://G:\Bulletin Board\UP-02.doc"
(I'm not sure if there is a way to create a macro to do this part, if there is that would be fine as well, since I have the rest in a macro right now anyway.)

Then I would like it to simply close that form.

If you need any more specifics, let me know. Thank you!
 
If you are getting that error then you typed the code into the wrong place. Check out this to see where to put it:

http://www.btabdevelopment.com/main/QuickTutorials/Wheretoputcodeforevents/tabid/56/Default.aspx

hmm...I'm not sure I understand. Would that still apply here? I have a macro set on the "On Click" event, which is;

Condition: [Forms]![frmGWO1]![UP Billing Flag]="UP-02"
Action: RunCode
Arguments: OpenWordDoc

I have a module named "OpenWordDoc" which has this code:

Option Compare Database

Function OpenWordDoc()
FollowHyperlink "file://G:\Bulletin Board\doc.doc"
End Function
 
First try fixing your Hyperlink code because you need three forward slashes:

FollowHyperlink "file:///G:\Bulletin Board\doc.doc"

Second - you can't have the module named the same as the function. Change the module to modOpenWordDoc.
 
Ok I added an extra / in there, so now it reads...

Function OpenWordDoc()
FollowHyperlink "file:///G:\Bulletin Board\ExxonMobil\UP Billing Flags\UP 1.2 - Health and Safety Plan.doc"
End Function

Renamed the module to "modOpenWordDoc"

yet I'm still getting...

the object doesn't contain the automation object "OpenWordDoc"

The function name should still be "OpenWordDoc" right? Do I need to move the module somewhere perhaps, how does it know where to look for that function?
 
I think you need to also set it PUBLIC:

Public Function OpenWordDoc
 

Users who are viewing this thread

Back
Top Bottom