Pass ID Of Row In Click Event

IgnoranceIsBliss

Registered User.
Local time
Today, 04:11
Joined
Jun 13, 2019
Messages
35
@arnelgp in another thread of mine gave me a function that would open a form filtered to show only the specific ID information for the row I clicked on my form.

My database became corrupted and I had to re-create it and now it is not working. In the double click event of the field on my form I have the code
Code:
=OpenNotes("ID", [Comments])

And I have that method coded like this
Code:
Public Function OpenNotes(pkName As String, pkValue As Variant)
Dim strWhere As String
Select Case TypeName(pkValue)
Case "String" Then
    strWhere = pkName & " = '" & pkValue & "'"
Case "Integer", "Long", "Double", "Single"
    strWhere = pkName & " = " & pkValue
Case "Date"
    StrWhere = pkName & " = #" & Format(pkValue, "mm/dd/yyyy") & "#"
End Select
DoCmd.OpenForm FormName:="theFormToOpen", View:=acNormal, WhereCondition:=strWhere
End Function

Now when I step thro the code, if I hover over pkName, I see
Code:
pkName = "ID"

And
Code:
pkValue = the value of comments

HOWEVER it is comments for all records, not for the ID of the clicked row. What did I set-up incorrectly here in the redo?
 
Hi. What happens if you try it this way?
Code:
=OpentNotes("ID",[ID])
 
Yes, that is it perfectly!! Thank you for the assistance.
 

Users who are viewing this thread

Back
Top Bottom