Running Access 2003 VB Module code example

G

Guest

I got a code example of how to create a Module from the Microsoft Knowledge
base on how to fix a problem with a hyperlink field.

The example is
at:http://support.microsoft.com/default.aspx?scid=kb;en-us;323202&Product=acc2000

The module works when I edit and and press the F5 key to run it, but how do
I get it to run automatically without having to do that? I need it to run
automatically.

I have used VB Module code before that I embedded on the Data Entry form.

Thanks to all replies.
 
G

Guest

It depends on what you mean by automatically. Everything in Access is driven
by events, like when a form opens, when a button is clicked, when a value is
updated, etc. Depending on which event you want to trigger your code, you'd
call the code from the event handler. For example, if you want it to run when
a button is clicked, select the button in design mode. Find the OnClick event
on the control's property sheet, and click the small elipsis (...) button to
the right of the property. If prompted to choose a builder, select "Code
Builder". This will open the code window to the click event's handler. From
here, simply type the name of the routine you want to run (in your case,
UpdateHyperlinkToMail). Now when the button is clicked, it will run that code.

Barry
 
G

Guest

I understand that, but I would want the code to run when someone clicks on
the close form button, which already has this On Click code:

Private Sub Command22_Click()
On Error GoTo Err_Command22_Click

DoCmd.Close
Exit_Command22_Click:
Exit Sub
Err_Command22_Click:
MsgBox Err.Description
Resume Exit_Command22_Click
End Sub

Is there a place in here I can insert a line to have it run the
UpdateHyperlinkToMail routine ?

Thanks
 
G

Guest

Private Sub Command22_Click()
On Error GoTo Err_Command22_Click

UpdateHyperlinkToMail
DoCmd.Close

Exit_Command22_Click:
Exit Sub
Err_Command22_Click:
MsgBox Err.Description
Resume Exit_Command22_Click
End Sub


Barry
 
G

Guest

Ok that works great - but then I get a message box that says "update
complete" that the user has to click on to clear. Is there a way to get rid
of that message box ? That would be perfect, and you've taught me a lot
already.

Thanks much for your help
 
G

Guest

Look at the code inside the UpdateHyperlinkToMail procedure. Find the line
that says:
MsgBox "Update Complete!"
and delete it.

Barry
 
G

Guest

Ooops sorry, Barry - I already figured out how to fix that by just taking the
Mesage Box line out of the module code.

Thanks for the prompt response and great instruction.

Do you have a website or a book out?
 

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