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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

form & subform hyperlink to open form with value of hyperlink field

Status
Not open for further replies.

08211987

Programmer
Apr 20, 2012
187
US
Hi,
I have a form and a subform. When the form opens it displays all Item Numbers that are for a particular project which is determined when the form opens. That all works correctly. I then have a hyperlink on the Item Numbers and want to open a detailed form for that particular Item number. For some reason it is opening the detailed form for the 1st Item Number for that project.

This is my code for the click event for the Item Number:
Private Sub Item_Nbr_Click()
Debug.Print "Item nbr = "; Me.Item_Nbr
hold_Item_Nbr = Me.Item_Nbr
DoCmd.Close acForm, Me.Name, acSaveNo
DoCmd.OpenForm "form_Initiative_Item_Detail", , , "Item_Nbr = " & hold_Item_Nbr, acFormEdit
End Sub

On the Debug.Print value it shows the 1st Item number on the previous form and not the one I clicked.

Would someone know why the Me.Item_Nbr not be the value of the Item_Nbr clicked but be the 1st one listed in the list?

Thanks for any assistance!
 
Would it help if you would hold on to the item number you clicked on?
something like:

Code:
Option Explicit
Dim [blue]intMyItemNo[/blue] As Integer
...
Private Sub hyperlink_field_Click()
[blue]intMyItemNo[/blue] = hyperlink_field_value
End Sub

Private Sub Item_Nbr_Click()
 Debug.Print "Item nbr = " & [blue]intMyItemNo[/blue]
 hold_Item_Nbr = [blue]intMyItemNo[/blue]
 DoCmd.Close acForm, Me.Name, acSaveNo
 DoCmd.OpenForm "form_Initiative_Item_Detail", , , "Item_Nbr = " & [blue]intMyItemNo[/blue], acFormEdit
 End Sub

Have fun.

---- Andy

There is a great need for a sarcasm font.
 
Thanks for responding Andy,
I guess I am confused of what field the hyperlink_field_Click() is because the field that contains the hyperlink is what is being performed in Item_Nbr_Click().
Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top