Results 1 to 9 of 9
  1. #1
    angie is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Dec 2013
    Posts
    232

    Code to add to a text box

    I have the following code that works great, but the one thing that is not working is the me.proposal ="apco air"
    It will delete the information that is already in the Proposal and replace it with Apco Air I want it to add Apco Air to the next line in the Proposal with out deleting the information already there.
    Thanks Angie

    Private Sub ApcoAir_AfterUpdate()
    If Me.ApcoAir = True Then
    Me.ApcoAirPrice = "850"
    Else
    Me.ApcoAirPrice = Null
    End If
    Me.Proposal = "Apco Air"
    Me.Refresh



    End Sub

  2. #2
    jwhite is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Dec 2012
    Location
    North Carolina
    Posts
    349
    Seems odd, but: Me.Proposal = Me.Proposal & vbCrLf & "Apco Air"

  3. #3
    angie is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Dec 2013
    Posts
    232
    Quote Originally Posted by jwhite View Post
    Seems odd, but: Me.Proposal = Me.Proposal & vbCrLf & "Apco Air"
    This Works great, but if after I checked the yes/no box itadded the “Apco Air” which is great but if I wanted it to remove it if I uncheckedthe box could this be done?

  4. #4
    jwhite is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Dec 2012
    Location
    North Carolina
    Posts
    349
    At this point I question what it is you are trying to accomplish. The reason I said "Seems odd.." earlier is you normally wouldn't have a checkbox on a form and when checked append text to another textbox, and especially now if unchecked, you want it removed. Logically I would check the status of the checkbox in the Form BeforeUpdate event and then update the textbox right before Access saves the record. Then again, if the checkbox is ticked, you know it is "Apco Air" so instead of appending/removing the string value in the textbox, just include code where need to check if the checkbox is true/false and proceed accordingly (presuming the checkbox is hooked to a field in a table).

  5. #5
    angie is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Dec 2013
    Posts
    232
    I have a form that we use for selling. We can add items my using a check box that would add additional add on items that are not included.
    When the check box is true it fills in the Cost in one field and adds the items to another text box. If the customer decides they do not want the item we have to uncheck the box and it removes the price from the text box but does not remove the item that was added to the proposal. So I guess it would be a true or false statement that would show the item in the proposal text box or not.

    Private Sub ApcoAir_AfterUpdate()
    If Me.ApcoAir = True Then
    Me.ApcoAirPrice = "850"
    Me.Proposal = Me.Proposal & vbCrLf & "Install Apco Air"
    Else
    Me.ApcoAirPrice = Null
    End If
    Me.Refresh

    End Sub

  6. #6
    jwhite is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Dec 2012
    Location
    North Carolina
    Posts
    349
    I see. Each item ordered/sold should be in a separate record. For example, you have a table named tblOrders, then you have a table named tblOrderDetails which tracks each item that is ordered. Then, if the customer changes their mind, you simply delete the entire row for that item from tblOrderDetails. While you may get it work with the convoluted approach above, I would HIGHLY not recommend it.

  7. #7
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Should not store multiple discrete data into one field of table.

    Why does this data have to be in the same field and textbox?

    Have the check box and then have expression in another textbox that will dynamically display (or not display) the text depending on value of yes/no field.
    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.

  8. #8
    angie is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Dec 2013
    Posts
    232
    Hi June. It for a proposal, it already has a list of items but if I need to add additional items by using a checkbox to add item. The above works great but if I made a mistake and checked the box and then uncheck it I have to delete the item that was added.

  9. #9
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    I agree with jwhite. Think you need to reconsider this approach and redesign db structure.
    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. Replies: 18
    Last Post: 03-01-2017, 11:59 AM
  2. run code from text box
    By Jen0dorf in forum Access
    Replies: 6
    Last Post: 11-13-2015, 02:59 PM
  3. Converting a Code to Text
    By rmcafee in forum Programming
    Replies: 7
    Last Post: 09-13-2011, 08:52 PM
  4. code for blank text ???
    By alex_raju in forum Access
    Replies: 1
    Last Post: 08-02-2011, 07:50 PM
  5. Code in combobox, code in text box
    By float in forum Forms
    Replies: 3
    Last Post: 09-29-2010, 07:12 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