Go Back   Access World Forums > Microsoft Access Discussion > General

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 09-06-2019, 07:47 AM   #1
silversun
Newly Registered User
 
Join Date: Dec 2012
Posts: 53
Thanks: 25
Thanked 0 Times in 0 Posts
silversun is on a distinguished road
How to make a row selectable in a table

Hi everybody,
I have a subform based on a select query. I need to store the content of one of the controls in selected row (an ID) for later use. Users usually hover on the rows then select or click on one of them. I don't know how I can make my table rows selectable like that. Is there someone who can help me on that?

silversun is offline   Reply With Quote
Old 09-06-2019, 07:50 AM   #2
theDBguy
Iím here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 5,896
Thanks: 57
Thanked 1,288 Times in 1,269 Posts
theDBguy has a spectacular aura about theDBguy has a spectacular aura about
Re: How to make a row selectable in a table

Hi. Not sure I follow. Are you able to post some images demonstrating what you mean? Thanks.
__________________
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 offline   Reply With Quote
Old 09-06-2019, 09:22 AM   #3
silversun
Newly Registered User
 
Join Date: Dec 2012
Posts: 53
Thanks: 25
Thanked 0 Times in 0 Posts
silversun is on a distinguished road
Re: How to make a row selectable in a table

@ theDBguy
Sure, Here is the image attached.
When user selects Patrick from customers combo box then all cars belong to Patrick are displayed in subform as you can see in the image.
Now user clicks on one of them, for example Mazda MX-5 is selected by user then subform sends the value of carOwner_ID to a variable in the VBA module so that I can store it later on in tbl_services. The value in this example is 12. To make it more user friendly I prefer to have a row highlighted when user hovers on them.
I hope you got the idea. My English is not very well but I am trying my best to deliver my idea as simplest as I can.

silversun is offline   Reply With Quote
Old 09-06-2019, 09:28 AM   #4
theDBguy
Iím here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 5,896
Thanks: 57
Thanked 1,288 Times in 1,269 Posts
theDBguy has a spectacular aura about theDBguy has a spectacular aura about
Re: How to make a row selectable in a table

Quote:
Originally Posted by silversun View Post
To make it more user friendly I prefer to have a row highlighted when user hovers on them.
Hi. Thanks for the additional information. You can highlight a row when the user clicks on it, but doing it during a mouse hover is a little tricky.
__________________
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 offline   Reply With Quote
The Following User Says Thank You to theDBguy For This Useful Post:
silversun (09-07-2019)
Old 09-06-2019, 09:34 AM   #5
pbaldy
Wino Moderator
 
pbaldy's Avatar
 
Join Date: Aug 2003
Location: Nevada, USA
Posts: 33,296
Thanks: 13
Thanked 4,112 Times in 4,044 Posts
pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold
Re: How to make a row selectable in a table

In the current event of the subform you can have:

VariableName = Me.carOwner_ID

presuming the variable is declared as public in a standard module, any time a record is selected the variable will be populated with the ID and be available for use elsewhere.
__________________
Paul
Microsoft Access MVP 2007-2019

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
pbaldy is offline   Reply With Quote
The Following User Says Thank You to pbaldy For This Useful Post:
silversun (09-07-2019)
Old 09-06-2019, 10:09 AM   #6
theDBguy
Iím here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 5,896
Thanks: 57
Thanked 1,288 Times in 1,269 Posts
theDBguy has a spectacular aura about theDBguy has a spectacular aura about
Re: How to make a row selectable in a table

Quote:
Originally Posted by pbaldy View Post
In the current event of the subform you can have:

VariableName = Me.carOwner_ID

presuming the variable is declared as public in a standard module, any time a record is selected the variable will be populated with the ID and be available for use elsewhere.
Hi silversun. I agree with Paul. But again, the current event and the record being selected means the user has to "click" on it. Hovering doesn't select a record, if that's what you were asking.
__________________
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 offline   Reply With Quote
The Following User Says Thank You to theDBguy For This Useful Post:
silversun (09-07-2019)
Old 09-06-2019, 10:22 AM   #7
pbaldy
Wino Moderator
 
pbaldy's Avatar
 
Join Date: Aug 2003
Location: Nevada, USA
Posts: 33,296
Thanks: 13
Thanked 4,112 Times in 4,044 Posts
pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold
Re: How to make a row selectable in a table

I may have misread. I thought there were two different requests with the hover option as the ideal. Now that I reread it sounds like it's already working with the click, so sorry for jumping in.

__________________
Paul
Microsoft Access MVP 2007-2019

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
pbaldy is offline   Reply With Quote
Old 09-06-2019, 02:35 PM   #8
isladogs
High Noon Moderator
 
isladogs's Avatar
 
Join Date: Jan 2017
Location: Somerset, UK
Posts: 11,011
Thanks: 114
Thanked 3,014 Times in 2,741 Posts
isladogs is a splendid one to behold isladogs is a splendid one to behold isladogs is a splendid one to behold isladogs is a splendid one to behold isladogs is a splendid one to behold isladogs is a splendid one to behold isladogs is a splendid one to behold
Re: How to make a row selectable in a table

It is possible to 'select' a record using mouse move but it involves some complex code to determine the position of the mouse cursor on screen and the contents of the form in exactly the same position.
See this link for an example using listboxes Accurately Move Forms and Controls.

Whether its worth the effort involved in doing this is another matter
__________________
If this answer has helped, please click the Thanks button and/or click the 'reputation scales' symbol on the left.

Website links:
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.
,
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.


Colin (Mendip Data Systems)
Access 2010 32-bit, Access 2016 32-bit & 64-bit, SQL Server Express 2014, Windows 10,
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.


"As we know, there are known knowns; there are things we know we know. We also know there are known unknowns; that is to say we know there are some things we do not know. But there are also unknown unknowns Ė the ones we don't know we don't know. It is the latter category that tend to be the difficult ones" Donald Rumsfeld
isladogs is offline   Reply With Quote
Old 09-07-2019, 04:46 AM   #9
MajP
Newly Registered User
 
Join Date: May 2018
Location: USA baby
Posts: 1,848
Thanks: 36
Thanked 563 Times in 532 Posts
MajP has a spectacular aura about MajP has a spectacular aura about
Re: How to make a row selectable in a table

As stated the hover requires a lot of code, but the click is very simple to highlight a row. If the click suffices then.
code in subform
Code:
Private Sub Form_Current()
  Me.Tag = Nz(Me.carID)
  Me.Refresh
End Sub

Private Function IsSelected()
  IsSelected = (Nz(Me.carID) = Me.Tag)
End Function
Then using conditional format
Expression: IsSelected()



Attached Images
File Type: jpg Conditional.jpg (56.0 KB, 69 views)
File Type: jpg SelectedRow.jpg (21.7 KB, 68 views)
MajP is offline   Reply With Quote
The Following User Says Thank You to MajP For This Useful Post:
silversun (09-07-2019)
Old 09-07-2019, 06:02 AM   #10
arnelgp
error reading drive A:
 
arnelgp's Avatar
 
Join Date: May 2009
Location: somewhere out there
Posts: 8,568
Thanks: 68
Thanked 2,744 Times in 2,629 Posts
arnelgp is just really nice arnelgp is just really nice arnelgp is just really nice arnelgp is just really nice arnelgp is just really nice
Re: How to make a row selectable in a table

you could just add an unbound textbox and on current set it to the current record's ID.

cf [ID]=[txtUnbound]

no need for additional code and tag.
__________________
"Never stop learning, because life never stops teaching"
arnelgp is offline   Reply With Quote
Old 09-07-2019, 08:06 AM   #11
MajP
Newly Registered User
 
Join Date: May 2018
Location: USA baby
Posts: 1,848
Thanks: 36
Thanked 563 Times in 532 Posts
MajP has a spectacular aura about MajP has a spectacular aura about
Re: How to make a row selectable in a table

Code:
no need for additional code and tag
Or simply paste my solution and no need for an unnecessary unbound control. However, the additional two lines of code could be extremely problematic (insert sarcasm emoji).
MajP is offline   Reply With Quote
Old 09-07-2019, 11:40 AM   #12
silversun
Newly Registered User
 
Join Date: Dec 2012
Posts: 53
Thanks: 25
Thanked 0 Times in 0 Posts
silversun is on a distinguished road
Re: How to make a row selectable in a table

@ MajP
It works perfect. Thank you
silversun is offline   Reply With Quote
Old 09-07-2019, 12:22 PM   #13
theDBguy
Iím here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 5,896
Thanks: 57
Thanked 1,288 Times in 1,269 Posts
theDBguy has a spectacular aura about theDBguy has a spectacular aura about
Re: How to make a row selectable in a table

Quote:
Originally Posted by silversun View Post
@ MajP
It works perfect. Thank you
Hi. Glad to hear you got it working. 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 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
Combo Box values not Selectable paul.raeburn Forms 1 08-15-2011 02:05 PM
Listbox not selectable emorris1000 Forms 3 08-11-2011 01:16 PM
make a text box not selectable Darth Vodka Forms 18 01-22-2008 04:56 AM
Table Within a Form - Selectable BrianB75 Forms 1 08-27-2004 09:36 AM
Multi Tables Selectable from a Second table. stewartrose Tables 10 08-12-2003 10:10 AM




All times are GMT -8. The time now is 11:42 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