Results 1 to 4 of 4
  1. #1
    larry11 is offline Novice
    Windows 10 Access 2016
    Join Date
    Jun 2017
    Location
    London, England
    Posts
    10

    After Update Event, Populate Text Box Based on Contents of a Textbox and Dropdown List

    Hello, Good morning!

    I am hoping someone can please help me with an after Update problem I am having within a form in an Access 2016 database.

    I have a textbox (TextboxA1) that I would like to populate based on criteria firstly within a textbox and secondly in a dropdown list, but only if both criteria are met.

    Data Source 1. (Text Box)
    Within another text box there are various coma separated values, for example;

    Wool Jumpers, Cotton T Shirts, Trousers,

    Data Source 2. (Drop Down List)

    List of 4 options;


    1. (Blank - Empty cell, No Contents)
    2. Small
    3. Medium
    4. Large


    Examples of a Query

    If "Wool Jumpers" is contained anywhere in Source 1. AND Source 2. is "Small" - Show "Wool Jumpers Small" in the TextboxA1

    If "Wool Jumpers" is contained anywhere in Source 1. AND Source 2. is "Large" - Show Wool Jumpers Large" in the TextboxA1

    If "Wool Jumpers" is Contained anywhere in Source 1. And Source 2. is Blank - Empty Cell, No Contents - Show nothing (remain blank) in TextboxA1

    If "Wool Jumpers" is NOT contained anywhere in Source1. AND Source 2. is "Large" - Empty Cell, No Contents - Show nothing (remain blank) in TextboxA1. (Both criteria must be met to show a result)

    If the criteria is met and shows but then either of the sources are changed to not satisfy the requirements then the TextboxA1 is again blank.

    I hope I have explained this clearly.

    May I also thank you in advance for any assistance you can offer.

    many thanks

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722
    Tell us about the business processes involved, so we have some context for your issue/question.
    What are your tables and relationships ? Please post a jpg of your relationships window.

  3. #3
    larry11 is offline Novice
    Windows 10 Access 2016
    Join Date
    Jun 2017
    Location
    London, England
    Posts
    10
    Hello

    Thank you for your response;

    To try and answer your questions,

    The database is built using only 1 table, I am using it to send emails that address potential clients queries regarding the products we offer and their availability

    Within the mail merge there are "Rules" that make the email more relevant to the clients questions, and as the merge fields are used to trigger the "Rules" I need to have slightly different merge field contents, for example "Wool Jumpers, Large" This would add the paragraph in the mail merge Rules that gives details about Large wool jumpers as opposed to for example "Small Wool Jumpers"

    I have been trying to get it to work and have the following which almost works! except that if it has updated with "Large" selected from source 2 and then I change it to small TextboxA1 does not change but stay showing the original "Wool Jumpers; Large" - although if you delete the "Wool Jumpers" form Source 1 it doe s show nothing (which is right and obviously triggered by the "Else """ part of the code.

    Private Sub Data_Source_1_AfterUpdate()
    If Me.Data_Source1 Like "*Wool Jumpers*" Then
    Me.TextboxA1 = "Wool Jumpers; " & Me.DataSource_2
    Else
    Me.TextboxA1 = ""
    End If

    End Sub

    I hope this give you a better idea of what I am trying to do.

    thank you again for taking the time to help.

  4. #4
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,405
    You need the same update code to run when DataSource_2 is changed:
    Code:
    Private sub DataSource_2_AfterUpdate()
        Call Data_Source_1_AfterUpdate
    End Sub
    Last edited by davegri; 06-24-2017 at 08:01 AM. Reason: clarif

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

Similar Threads

  1. Replies: 2
    Last Post: 05-17-2017, 09:49 AM
  2. Replies: 2
    Last Post: 12-20-2016, 08:55 AM
  3. Replies: 13
    Last Post: 09-10-2015, 03:37 PM
  4. Replies: 1
    Last Post: 05-06-2014, 09:14 PM
  5. Replies: 2
    Last Post: 08-03-2010, 10:16 AM

Tags for this Thread

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