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

    Hello and Good Morning,



    I am a new member to the forum and was hoping someone could please help me with a problem.

    I have a check box on a form and I would like that when the checkbox is "checked" or "true" that some text is added to a text box (I am using the textbox as a data source for a mail merge after I export it using excel).

    I have, after various efforts now got the text I want to be added to the textbox being added; (without deleting anything else that is in the textbox).

    What I want is so that if the text box is unticked (or False), then no text is added to the text box or any text it has already added is removed (and the original text in the text box, if any, remains).

    Top summarise it is if true add this to the text box, if False add nothing to the text box (or remove what you have already added).

    what I have got so far is as below.

    Private Sub Bencalculator_AfterUpdate()
    If Me.Bencalculator = True Then
    Me.Benefit_Type = Me.Benefit_Type & "Benefit Search Calculator"
    End If

    End Sub

    NB;
    Bencalculator is the checkbox
    Benefit_Type is the textbox
    "Benefit Search Calculator" is the text to be added/ removed to the textbox (without deleting any other text).

    I have search on the internet but can not seem to find the Else or Then action or description I am looking for.

    I thank you in anticipation of any help you can offer,

    thank you.

  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,815
    Maybe:
    Code:
    Private Sub Bencalculator_AfterUpdate()
    If Me.Bencalculator = True Then
         Me.Benefit_Type = Me.Benefit_Type & "Benefit Search Calculator"
    Else
         Me.Benefit_Type = Replace(Me.Benefit_Type, "Benefit Search Calculator", "")
    End If
    End Sub
    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
    larry11 is offline Novice
    Windows 10 Access 2016
    Join Date
    Jun 2017
    Location
    London, England
    Posts
    10
    Hello,

    thank you very much for your very quick response, I have tried the code and it does add and remove the text as requested, however, if you have added or "checked" the checkbox and then decide that you want to "uncheck" it, whilst it does remove the text as required it leaves a coma, (and an additional coma each time you add and remove it); Is there a way that it would not leave a coma if it were unchecked? (I am just thinking that the coma could be picked up in a csv file).

    Thank you again for your help.

  4. #4
    larry11 is offline Novice
    Windows 10 Access 2016
    Join Date
    Jun 2017
    Location
    London, England
    Posts
    10
    hello again,

    I found where the coma was coming from and now it works perfectly! Many thanks for your help and sorry to have troubled you with the coma query.

    thank you again,

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

Similar Threads

  1. Replies: 6
    Last Post: 11-05-2014, 05:27 PM
  2. Replies: 7
    Last Post: 05-08-2014, 10:34 AM
  3. After Update event help
    By noaccessguru in forum Forms
    Replies: 9
    Last Post: 08-08-2013, 12:36 AM
  4. Before Update Event Help
    By bklewis in forum Access
    Replies: 8
    Last Post: 03-25-2012, 03:58 PM
  5. Before Update Event
    By randolphoralph in forum Programming
    Replies: 0
    Last Post: 06-15-2010, 09:26 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