Results 1 to 4 of 4
  1. #1
    Ekhart is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jun 2016
    Posts
    80

    Query criteria based on user

    Is there a way to code a criteria on my query to sort out an alpha split for the user running the report?
    On my form the user selects their name in the cboUserName field and selects the report to run. The report is based on a query. Each user has an alpha split in the tblUpdatedEmployees table.
    An example would be Paul selects his name, his alpha split in the table is ABC, using the below criteria will filter just these out. The problem is the only way it works is that it will prompt me to enter the alpha split manually when this is run, I can't seem to get it to look at the user selected on the form (frmUpdatedLogin) to select the proper alpha split automatically. Each user has a unique UserID on the tblUpdatedEmployees table but the issue I have is that there are no other like fields between this table and the Scheduler_Sheet table to create a relationship.



    I know I can do multiple queries, however I am trying to keep this editable. Is my only option to filter these out on the end result form/report?

    Code:
    InStr([tblUpdatedEmployees].[Alpha],Left([Scheduler_Sheet].[LastName],1))

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    This 'Split' is just the first 3 letters of employee last name? What if multiple employees have the same 3 letters?

    The report query has this Split value in the records?

    I expect you would want to apply the filter criteria at the time the report is opened.

    How does user select their name - from a combobox? The combobox can have multiple columns. One of those columns can hold the Split value. That column can be referred to by column index.
    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
    Ekhart is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jun 2016
    Posts
    80
    The split is random letters, in this case the first letter of the last name for the record they are pulling up (the example would pull up any last name beginning with A, B or C).
    I did add the alpha to the combo box however I am unsure how to reference that in the query criteria. I am able to set this on on the report or form that uses what the query pulls, but I am curious if there is a way to do it on the query itself. Unfortunately our network is slow and there is little I can do about it so the more data I can weed out sooner in the process, the better.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Unfortunately, Access query will not recognize reference to combobox or listbox column index. An expression in textbox can: = [combobox].Column(x). Column index begins with 0, so if value is in column 3, then index would be 2.

    Query can reference the textbox.

    WHERE Alpha = [Forms]![formname]![textboxname]
    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.

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

Similar Threads

  1. Criteria based on user input
    By vincentsp in forum Queries
    Replies: 4
    Last Post: 03-25-2015, 10:46 AM
  2. Replies: 1
    Last Post: 01-04-2014, 11:04 PM
  3. Criteria based on user input
    By Alsail77 in forum Queries
    Replies: 5
    Last Post: 08-16-2012, 02:19 PM
  4. Selecting records based on criteria from user input
    By shabbaranks in forum Programming
    Replies: 1
    Last Post: 01-04-2012, 09:06 AM
  5. Replies: 6
    Last Post: 07-22-2010, 05:53 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