Solved

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

Posted on 2014-07-28
8
1,895 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 100 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
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 
LVL 85

Assisted Solution

by:Scott McDaniel (Microsoft Access MVP - EE MVE )
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 100 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 100 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 200 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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

726 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