Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hyperlink Functionality

Status
Not open for further replies.

Mary10k

IS-IT--Management
Nov 8, 2001
103
US
Hello,
I have a data sheet view form with a column titled "Patient Name". I would like the users to be able to click on a name from the Patient Name field and have that open to another form called "Details", but I would like the Details form to default to the selected record.

Any advice how to get the form to oppen the corresponding record?
Thanks.
 
You could use the DoubleClick event for the Patient Name textbox and then use the Where condition of the OpenForm Action

Private Sub txtPatientName_DblClick(Cancel As Integer)
DoCmd.OpenForm "Details", , , "[Patient Name] = '" & Me.txtPatientName & "'"
End Sub

PaulF
 
Thank you. This works with getting the record I want, but I would like to display the selected name on the Details form. Any suggestions how I would do that?

Thanks.
 
Use DLookup("[Namefield]", "Table", "[PatientID]=" & patientID) to get the name from the patients table.

VBSlammer
redinvader3walking.gif

[sleeping]Unemployed in Houston, Texas
 
Hello,
I tried the DLookup function and verified my syntax, but I keep getting an error "#Error" in the text box. Any suggestions?
 
If you are using DLookup, there is a chance there is no record. Use the Nz function.
=Nz(DLookup(......), "")
to display a blank, "".

Richard
 
Still no success with the Nz function. Any advice?
 
The most common reason is that the text box has the same name as a field. When you use an aggregate function in a textbox, you need to rename the textbox something like "txtPatientName" and the error will go away.

VBSlammer
redinvader3walking.gif

[sleeping]Unemployed in Houston, Texas
 
Mary

Right now we are guessing because we really do not have all the info. "We" probably know a dozen ways or more to do what you want, but we need specifics to provide you with specific information.

We need to know the name of the table or tables and associated fields that are also involved.

We also need to know the name of the control objects (text boxes, combo boxes) on the form that have anything to do with what you are attempting. If there is more than one form used, we need to know the names of each form.

We also need to know the ControlSource for these same objects.

Lastly, it would be helpful to now the RowSource and bound column info for any combo or list boxes that are involved.

I suspect the error is caused by a syntax error or a typo.

And just in case you do not know how to find the name of a control object on the form, open the form in Design mode. Make sure you have the Properties window open. (From the menu, "View" -> "Properties")

Click on a text box, list box or combo box that you want to identify. Now select the "Other" tab in the "Properties" window, and note the value in the "Name" field -- this is the name of the control on the form. (By the way, you can change the name to a more menaingful name on the form -- this really helps when writing code, or defining sort order. When a control is created with the form wizard, it will default to the name of the ControlSource. If the object is created manually, then Access uses its own naming convention, Text02, Combo04, etc)

Now to get the name of the ControlSource, RowSource and BoundColumn, click on the "Data" tab in the property window.

Richard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top