?
Solved

MS Access Record Selector Question...Can I use them to select a record?

Posted on 2014-07-28
8
Medium Priority
?
1,952 Views
Last Modified: 2014-08-02
In an MS Access query, there is some sort of record selection device along the left of the query.
If you l click on this left edge, the entire row is highlighted.

Can I click on a row, the press a command button, and have the ability to select data from the selected row?

Lets say my query lists hundreds of items.  I would like to click one row then press a command button that I can use in my routines.

Possible?
0
Comment
Question by:pcalabria
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 13

Expert Comment

by:Russell Fox
ID: 40225787
I think your best bet will be to add a column like IsSelected and expose that in a form so the user can click each record they want to manipulate, then you can have another query "WHERE IsSelected = True" to just work on those records. You should probably use the form's OnLoad event to set all IsSelected to False. If you have multiple users, you may need to instead use their UserId instead of a boolean (WHERE UserSelected = CurrentUserID).
0
 

Author Comment

by:pcalabria
ID: 40225805
I'll give that a try.  So the other record selection process really is useless?
It's not just that I don't know how to use it?

IS there an easy way to convert from a query to a form?
0
 
LVL 13

Assisted Solution

by:Russell Fox
Russell Fox earned 400 total points
ID: 40225819
Yeah, it's really just for using the right-click options, like copy/delete. You can create a simple form with the form wizard, just use the query as the data source instead of the table.
0
What Is Blockchain Technology?

Blockchain is a technology that underpins the success of Bitcoin and other digital currencies, but it has uses far beyond finance. Learn how blockchain works and why it is proving disruptive to other areas of IT.

 
LVL 85

Assisted Solution

by:Scott McDaniel (Microsoft Access MVP - EE MVE )
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 400 total points
ID: 40226318
Queries don't fire Events, and other objects in the database cannot interact with a query in standard Datasheet view, so you'll have to do something along the line of what Russell suggests. You could also create a form and use a Listbox, with your query as the RowSource for the Listbox, if that would make more sense from a UI perspective.
0
 
LVL 58

Assisted Solution

by:Jim Dettman (Microsoft MVP/ EE MVE)
Jim Dettman (Microsoft MVP/ EE MVE) earned 400 total points
ID: 40226449
If you bind a form to a query, and then display it in data sheet view or continuous form view, you can let a user select records by using the SelLeft, SelTop, SelWidth, and SelWidth property.  In fact you can even determine the cells that are selected.

 These indicate the start row/col and the last row/col selected.

Jim.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 40227849
I would like to click one row then press a command button that I can use in my routines.

Can you explain clearly (with an example scenario) what you mean by this?

Perhaps I am not understanding, ...but if you want to :
    "click one row then press a command button"
...Then to me, you might be better off using Scott's listbox suggestion to display the query results.
Then you can retrieve, and use any field value from that row and use it in your "routines", ...something like this:
    Me.Yourlistbox.Column(n)

I do not want any points for my post, because I basically agree with Scott, ...I am just curious about these "Routines"
;-)


JeffCoachman
0
 
LVL 31

Accepted Solution

by:
Helen Feddema earned 800 total points
ID: 40229460
Make a datasheet form (or subform) bound to the query, and then add a DblClick event to a control.  Typically, this is used to open another form for the selected ID, like this, but you can run code or do something else using the ID:
Private Sub cboClientID_DblClick(Cancel As Integer)
'Created by Helen Feddema 18-May-2011
'Last modified by Helen Feddema 18-May-2011

On Error GoTo ErrorHandler

   Dim lngClientID As Long
   Dim strSearch As String
   Dim frm As Access.Form
   
   lngClientID = Nz(Me.ActiveControl.Value)
   
   If lngClientID <> 0 Then
      blnOpenMainMenu = False
      DoCmd.OpenForm "frmClients"
      strSearch = "[ClientID] = " & lngClientID
      Set frm = Forms("frmClients")
      frm.Recordset.FindFirst strSearch
      DoCmd.Close acForm, Me.Name
   End If
   
ErrorHandlerExit:
   Exit Sub

ErrorHandler:
   MsgBox "Error No: " & Err.Number _
      & " in " & Me.ActiveControl.Name & " procedure; " _
      & "Description: " & Err.Description
   Resume ErrorHandlerExit

End Sub

Open in new window

0
 

Author Closing Comment

by:pcalabria
ID: 40236579
Thanks all,

I replaced the query with a form based on the query and used the double click event of the for to run my code.  It works great.  All tried to distribute points based upon the amount of help yor responses gave me . Thanks!
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question