Results 1 to 4 of 4
  1. #1
    crobaseball is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2014
    Posts
    128

    Want a query to filter by one of 2 parameters

    I have a couple of different scenarios where I want to change the prices of in our price database. The way in which the database is set up, we have different suppliers, who in turn have different lines of products. I need to have the functionality where the person managing the db can change by supplier OR change by product line. e.g. - Company A increases across the board, whereas Company B might increase prices on a certain product line by 1% and a different product line by 1.5%. I can certainly write multiple queries to handle all of the possible scenarios, but I've got to think there's a cleaner way of doing this. Is there a way where I can use parameters from a form to determine which filter to select in a query? i.e., if they use the "supplier" part of the form to update prices, the query is used, but the only filter applied is for the "supplier", whereas if they use the "product line" part of the form, the SAME query is utilized, but the "product line" filter is applied.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,623
    I would use VBA to construct the UPDATE sql then run the sql in VBA:

    Dim strSQL As String
    'code to build string and set the variable
    CurrentDb.Execute strSQL
    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
    crobaseball is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2014
    Posts
    128
    So I haven't done much with programming in SWL. I take it that Update will allow me to create a new record?

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,623
    UPDATE only modifies existing records.

    INSERT creates a new record.
    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. Parameters in a query?
    By Carol Geddes in forum Queries
    Replies: 5
    Last Post: 11-05-2013, 05:00 PM
  2. Query/data parameters
    By sk88 in forum Access
    Replies: 2
    Last Post: 07-26-2012, 12:58 PM
  3. query help with parameters
    By Madmax in forum Access
    Replies: 2
    Last Post: 03-05-2012, 03:07 PM
  4. Msgbox in a query with parameters
    By seb in forum Forms
    Replies: 7
    Last Post: 07-06-2010, 05:07 AM
  5. Replies: 3
    Last Post: 07-01-2010, 07:55 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