Solved

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

Posted on 2014-07-28
8
1,812 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
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-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
LVL 84

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 57

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

820 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