Results 1 to 4 of 4
  1. #1
    GeorgeJ is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Dec 2014
    Posts
    67

    Move current record to correspond to record selected on Form

    I have a form “Chosen” which uses as its record source a query named “Chosen”. I set up this form as a tabular form so I can see more than one record at a time.
    Here is my question:

    As a test in the detail section of the form “Chosen” I created the subroutine
    Private Sub Detail_Click()
    Msgbox “Hello”
    End Sub

    And sure enough, every time I tab from one record to the next I get the message “Hello”
    Then I changed the subroutine to this

    Private Sub Detail_Click()
    Sub2
    End Sub

    Where sub2 is a public subroutine on another module (Module 1)

    Sub2
    Msgbox Chosen!Q_Num
    End Sub

    Now the value of Chosen!Q_Num should change depending upon what is the current record in query “Chosen” but the message I get is always the same – it always displays the value of Q_Num for the first record in the query rather than the record I am clicking on in the form. Is there any way to cause the current record in the Query to correspond to the record where my cursor is on the form?

    I have the following initialization code in Module1




    Option Compare Database
    Option Explicit
    Public DB As DAO.Database
    Public Questions As DAO.Recordset
    Public Chosen As DAO.Recordset

    Sub Init()
    Set DB = CurrentDb
    Set Questions = DB.OpenRecordset("Questions", dbOpenDynaset)
    Set Chosen = DB.OpenRecordset("Chosen", dbOpenDynaset)
    End Sub

    There is a query “Chosen” set up with SQL
    =” SELECT Questions.Chosen, Questions.Q_Num, Questions.Q_PrelimInfo, Questions.Q_Info
    FROM Questions
    WHERE (((Questions.Chosen)=True));”

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,820
    You are not referencing the form, you are referencing the public recordset object declared in Module1. The record pointer in the recordset is on the first record, therefore that's the value returned.

    Would have to do a search on the recordset to find the Q_Num value by using FindFirst method.

    What purpose does opening recordset of the data that is already available on form serve?

    What are you really trying to accomplish?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    GeorgeJ is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Dec 2014
    Posts
    67
    Thank you for your response. I'm new at this. At this point I just trying to create extremely simple diagnostic type routines in order to learn how to do stuff.

  4. #4
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716
    George,

    There is a lot of good material here --Crystal

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

Similar Threads

  1. Replies: 3
    Last Post: 12-11-2014, 11:26 AM
  2. Replies: 5
    Last Post: 11-06-2013, 02:49 PM
  3. Replies: 5
    Last Post: 06-16-2013, 05:25 PM
  4. Replies: 3
    Last Post: 02-11-2013, 04:43 PM
  5. Replies: 16
    Last Post: 02-06-2013, 03:06 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