Go Back   Access World Forums > Microsoft Access Discussion > Forms

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 09-12-2019, 06:50 AM   #1
IgnoranceIsBliss
Newly Registered User
 
Join Date: Jun 2019
Posts: 35
Thanks: 0
Thanked 1 Time in 1 Post
IgnoranceIsBliss is on a distinguished road
Pass ID Of Row In Click Event

@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?

IgnoranceIsBliss is offline   Reply With Quote
Old 09-12-2019, 06:54 AM   #2
theDBguy
Iím here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 4,146
Thanks: 46
Thanked 971 Times in 952 Posts
theDBguy will become famous soon enough theDBguy will become famous soon enough
Re: Pass ID Of Row In Click Event

Hi. What happens if you try it this way?
Code:
=OpentNotes("ID",[ID])
__________________
Just my 2 cents...

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
theDBguy is online now   Reply With Quote
Old 09-12-2019, 07:03 AM   #3
IgnoranceIsBliss
Newly Registered User
 
Join Date: Jun 2019
Posts: 35
Thanks: 0
Thanked 1 Time in 1 Post
IgnoranceIsBliss is on a distinguished road
Re: Pass ID Of Row In Click Event

Yes, that is it perfectly!! Thank you for the assistance.

IgnoranceIsBliss is offline   Reply With Quote
Old 09-12-2019, 07:06 AM   #4
theDBguy
Iím here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 4,146
Thanks: 46
Thanked 971 Times in 952 Posts
theDBguy will become famous soon enough theDBguy will become famous soon enough
Re: Pass ID Of Row In Click Event

Quote:
Originally Posted by IgnoranceIsBliss View Post
Yes, that is it perfectly!! Thank you for the assistance.
Hi. You're welcome. Glad we could assist. Good luck with your project.
__________________
Just my 2 cents...

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
theDBguy is online now   Reply With Quote
Old 09-12-2019, 12:29 PM   #5
Pat Hartman
Super Moderator
 
Join Date: Feb 2002
Location: Stratford,Ct USA
Posts: 27,988
Thanks: 13
Thanked 1,539 Times in 1,464 Posts
Pat Hartman is a name known to all Pat Hartman is a name known to all Pat Hartman is a name known to all Pat Hartman is a name known to all Pat Hartman is a name known to all Pat Hartman is a name known to all
Re: Pass ID Of Row In Click Event

Naming all PK's "ID" isn't particularly user friendly.

__________________
Bridge Players Still Know All the Tricks
Pat Hartman is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Double Click event not triggering After Update event George-Bowyer Modules & VBA 7 03-14-2019 11:50 PM
On Click event procedure skipping the On CLick code gblack Modules & VBA 3 05-06-2013 07:28 AM
pass list value to a text box on click event shutzy General 1 01-13-2012 01:51 AM
Form's Error Event takes precedence before Click event for Undo button Banana Forms 7 09-04-2008 04:15 PM
Click event has priority over exit event pbuethe Modules & VBA 5 06-22-2004 04:52 AM




All times are GMT -8. The time now is 09:52 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World