Open Dialog menu with button?

S

Stockwell43

Hello,

I was wondering if it is possible to open the dialog window to insert a
hyperlink in a textbox. For example:

On a form each record contains a project. I have a textbox that Procedure
field name "SOP". Next to the procedure field I have a command button. I
would like to click on the command button to search through the folder on our
network to hyperlink a procedure that pertains to the project. Can this be
done?

Thanks!!!
 
K

Ken Sheridan

In the button's Click event procedure put:

Me.[YourTextBox].SetFocus
RunCommand acCmdInsertHyperlink

where YourTextBox is the name of the control bound to the hyperlink field.

Ken Sheridan
Stafford, England
 
S

Stockwell43

Hi Ken,

Thank you for your reply!

Code works great except for one thing; If I decide to Cancel and close the
dialog box without creating the hyperlink, I get a debug message and this
line is highlighted in yellow:

RunCommand acCmdInsertHyperlink

Did I do something wrong? It seemed simple enough. Thank you!!

Ken Sheridan said:
In the button's Click event procedure put:

Me.[YourTextBox].SetFocus
RunCommand acCmdInsertHyperlink

where YourTextBox is the name of the control bound to the hyperlink field.

Ken Sheridan
Stafford, England

Stockwell43 said:
Hello,

I was wondering if it is possible to open the dialog window to insert a
hyperlink in a textbox. For example:

On a form each record contains a project. I have a textbox that Procedure
field name "SOP". Next to the procedure field I have a command button. I
would like to click on the command button to search through the folder on our
network to hyperlink a procedure that pertains to the project. Can this be
done?

Thanks!!!
 
K

Ken Sheridan

No, you did nothing wrong, but you need to trap and ignore the error:

Me.[YourTextBox].SetFocus
On Error resume Next
RunCommand acCmdInsertHyperlink

Ideally you should add some more code to make sure it’s the anticipated
error, which you can identify by its Err.Number. If its not the error
expected then a message box would be popped up to inform the user of the
unanticipated error. In fact good code should always include error handling
to allow the user to back out gracefully, even if no error is expected in the
normal course of things.

Ken Sheridan
Stafford, England

Stockwell43 said:
Hi Ken,

Thank you for your reply!

Code works great except for one thing; If I decide to Cancel and close the
dialog box without creating the hyperlink, I get a debug message and this
line is highlighted in yellow:

RunCommand acCmdInsertHyperlink

Did I do something wrong? It seemed simple enough. Thank you!!

Ken Sheridan said:
In the button's Click event procedure put:

Me.[YourTextBox].SetFocus
RunCommand acCmdInsertHyperlink

where YourTextBox is the name of the control bound to the hyperlink field.

Ken Sheridan
Stafford, England

Stockwell43 said:
Hello,

I was wondering if it is possible to open the dialog window to insert a
hyperlink in a textbox. For example:

On a form each record contains a project. I have a textbox that Procedure
field name "SOP". Next to the procedure field I have a command button. I
would like to click on the command button to search through the folder on our
network to hyperlink a procedure that pertains to the project. Can this be
done?

Thanks!!!
 
S

Stockwell43

Excellent, worked like a charm!!!! Thank you Ken, I appreciate your help!!!
I'll save this in my Code Book for future use. :eek:)

Have a great day!!

Ken Sheridan said:
No, you did nothing wrong, but you need to trap and ignore the error:

Me.[YourTextBox].SetFocus
On Error resume Next
RunCommand acCmdInsertHyperlink

Ideally you should add some more code to make sure it’s the anticipated
error, which you can identify by its Err.Number. If its not the error
expected then a message box would be popped up to inform the user of the
unanticipated error. In fact good code should always include error handling
to allow the user to back out gracefully, even if no error is expected in the
normal course of things.

Ken Sheridan
Stafford, England

Stockwell43 said:
Hi Ken,

Thank you for your reply!

Code works great except for one thing; If I decide to Cancel and close the
dialog box without creating the hyperlink, I get a debug message and this
line is highlighted in yellow:

RunCommand acCmdInsertHyperlink

Did I do something wrong? It seemed simple enough. Thank you!!

Ken Sheridan said:
In the button's Click event procedure put:

Me.[YourTextBox].SetFocus
RunCommand acCmdInsertHyperlink

where YourTextBox is the name of the control bound to the hyperlink field.

Ken Sheridan
Stafford, England

:

Hello,

I was wondering if it is possible to open the dialog window to insert a
hyperlink in a textbox. For example:

On a form each record contains a project. I have a textbox that Procedure
field name "SOP". Next to the procedure field I have a command button. I
would like to click on the command button to search through the folder on our
network to hyperlink a procedure that pertains to the project. Can this be
done?

Thanks!!!
 

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