Hi,
I have a search form and 2 buttons in it - one to search in table view and one to search in form view. In the search results page, there is an item no field and when I click on the field, the corresponding details for that particular item opens up in another form. So far so good.
So now I want the item No to be a hyperlink only in table view and not in form view. So I did some vb code to achieve that (I think the code is very crude, I am not the world's greatest programmer)
Code:
Public gblnHyperlink As Boolean 'Declare a global variable
Dim blnHyperlink As Boolean 'Declare a variable in the general declarations section in the search form
Private Sub searchForm_Click()
blnHyperlink = False
gblnHyperlink = blnHyperlink
End Sub
Private Sub searchTable_Click()
blnHyperlink = True
gblnHyperlink = blnHyperlink
End Sub
Private Sub Form_Load() 'In the load event of the search result form
If gblnHyperlink = true Then
Me.FPItem.IsHyperlink = True
Else
Me.FPItem.IsHyperlink = False
End If
End Sub
Private Sub Item_Click() 'In the click event of the textbox in the search results form
If Me.ItemNo.IsHyperlink = True Then
DoCmd.OpenForm "F_Hyperlink", , , "ItemNo='" & Me.ItemNo & "'", , acDialog
Else
Me.txtTemp.Value = 1 'Dummy variable I set. Cos if the else part is left blank then it always shows as hyperlink
End If
Now the problem is, the boolean value is set properly only the first time the search results form loads. It is not set the consecutive times. For example, if I want to open the results in table view the first time and I click on the 'table view' button, then the ItemNo is displayed as a hyperlink and I can click on it. But without closing the search results page, if I click on 'form view' button, then the ItemNo is displayed as a hyperlink .
I know I need to clear the flag, but not sure how. Anyone help me on this?