Solved

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

Posted on 2014-07-28
8
1,767 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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

777 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