Results 1 to 4 of 4
  1. #1
    ShostyFan is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2013
    Posts
    76

    record source

    I have a form and I want the record source of a dropdown box to change based on a criteria.



    as an OnOpen, I have:
    If Forms![frmMainMenu]![RepairAccess] = "Yes" Then
    Me.TransactionID.RecordSource = "Qry_Restricted_TransactionType"
    Else
    Me.TransactionID.RecordSource = "Qry_All_TransactionTypes"
    End If

    I have also tried as a BeforeUpdate event on the dropdown box field itelf:
    If Forms![frmMainMenu]![RepairAccess] = "Yes" Then
    Me.RecordSource = "Qry_Restricted_TransactionType"
    Else
    Me.RecordSource = "Qry_All_TransactionTypes"
    End If


    Each version creates errors and I have resorted to guess and check. Any help will be apreciated.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    A dropdown box (combobox ?) has a RowSource not RecordSource.

    Forms and Reports have RecordSource.
    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
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,114
    If the RepairAccess is a Yes\No field then you need to check for True or -1, not "Yes".
    Now, about the form, is it a continuous or datasheet one or a single form? If the later then you'll be fine but with continuous form all your records will change with the current one (the code should be in the Current event of the form). To achieve what you want in a continuous form is a bit more complicated, you need code in both the Enter and Exit events (or the GotFocus\LostFocus pair) to change the source from all to restricted on enter and back to all on exit so all records display properly.

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  4. #4
    ShostyFan is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2013
    Posts
    76
    Perfect.
    The form is a Single form so putting the code into the OnCurrent event worked perfectly.
    Thank you.

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

Similar Threads

  1. Report with no Record Source
    By NISMOJim in forum Reports
    Replies: 13
    Last Post: 07-19-2014, 02:29 AM
  2. Replies: 9
    Last Post: 02-12-2014, 04:32 PM
  3. Replies: 5
    Last Post: 09-18-2013, 09:15 PM
  4. Replies: 14
    Last Post: 05-25-2012, 02:40 AM
  5. Forms' Record Source
    By Progress2007 in forum Programming
    Replies: 11
    Last Post: 07-27-2009, 11:04 AM

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