Results 1 to 4 of 4
  1. #1
    zashaikh is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2017
    Posts
    182

    Macro Shortcut - Run a Macro to Open a Form on a Where Criteria that is highlighted somewhere in Acc

    Hello.



    I need some help figuring out if what I want to do is possible.

    I current have a form (frmAlpha) with the following code attached to a btnSearch:

    Private Sub btnSearch_Click()
    Me.GoToRecordID Me.txtRecordID
    End Sub

    I use this btnSearch to quickly jump to a specified RecordID

    When I run a standard select query, I would like to somehow click on the RecordID and be taken to frmAlpha at that specific RecordID. I no it is not possible to use a query in such a manner. But I had an idea.

    Is it possible that I could create a Macro (have have it displayed in my MS Access Ribbon) that open frmAlpha based on the RecordID that is HIGHLIGHTED in the query?

    In other words, lets say I run a select query. Then, in my query, I highlight RecordID "1234." Next, I would click the button on my Access Ribbon, and have frmAlpha open to where "1234" = frmAlpha.txtRecordID

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    I don't think it's possible. Most of us never let users see tables or queries, only forms and reports. What you describe is easy in that environment.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    zashaikh is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2017
    Posts
    182
    Yes. I know this would be possible in a Form. I do it all the time. But I make queries all the time, and it would be useful to be able to quickly jump to a specified RecordID in a Form from a query

  4. #4
    zashaikh is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2017
    Posts
    182
    For example, I thought that I could make a Macro with a few steps. Step 1 would be to run this code:

    Function CopyTextToClipboard()
    'PURPOSE: Copy a given text to the clipboard (using DataObject)
    'SOURCE: www.TheSpreadsheetGuru.com
    'NOTES: Must enable Forms Library: Checkmark Tools > References > Microsoft Forms 2.0 Object Library

    Dim obj As New DataObject
    Dim txt As String

    'Make object's text equal above string variable
    obj.SetText txt

    'Place DataObject's text into the Clipboard
    obj.PutInClipboard

    End Function



    Step Two would be to Open a Form based criteria from my clipboard

Please reply to this thread with any new information or opinions.

Similar Threads

  1. How to open second Form using a Macro
    By djclinton15 in forum Forms
    Replies: 4
    Last Post: 12-18-2015, 09:53 AM
  2. Replies: 2
    Last Post: 02-20-2015, 06:32 AM
  3. Replies: 7
    Last Post: 09-16-2014, 02:35 PM
  4. Macro to open report based on value in a form
    By iProRyan in forum Macros
    Replies: 2
    Last Post: 02-24-2014, 03:02 AM
  5. Replies: 2
    Last Post: 10-09-2013, 05:45 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums