Hey Everyone,
I created a subform based on a few columns. I then created a new form based on a query. I would like to click on one of the columns in the subform and have it open the form based on the item they clicked. Here is what I have done so far in attempts to get it to work:
Created a subform and placed it in a navigation form. While designing the subform I clicked on the column Audit ID and made it a hyperlink. In the onclick event I put the following code:
On the form frmcontacts I have the data record source set to a query. Then the text boxes on the form are linked to the fields based on the query. In the query in the Audit ID column under criteria I have txtauditid. I named it that because the first field on the frmcontacts is txtauditid. I feel as if I am missing something with passing the variable from the subform to the form frmcontacts.
So I am not sure what to change or where to go from this point.
I created a subform based on a few columns. I then created a new form based on a query. I would like to click on one of the columns in the subform and have it open the form based on the item they clicked. Here is what I have done so far in attempts to get it to work:
Created a subform and placed it in a navigation form. While designing the subform I clicked on the column Audit ID and made it a hyperlink. In the onclick event I put the following code:
Code:
Private Sub txtauditid_Click()
On Error GoTo myError
Dim varWhereClause As String
varWhereClause = "Audit ID = '" & Me.txtauditid & "'"
DoCmd.OpenForm "frmcontacts", , , varWhereClause
leave:
Exit Sub
myError:
MsgBox Error$
Resume Next
End Sub
On the form frmcontacts I have the data record source set to a query. Then the text boxes on the form are linked to the fields based on the query. In the query in the Audit ID column under criteria I have txtauditid. I named it that because the first field on the frmcontacts is txtauditid. I feel as if I am missing something with passing the variable from the subform to the form frmcontacts.
So I am not sure what to change or where to go from this point.