Page 2 of 2 FirstFirst 12
Results 16 to 29 of 29
  1. #16
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664

    This update event does not work

    Okay, I created an update event for the txtBody control. In the form_current Sub txtBody is Null.

    After, I put picture in it, it is clearly no longer null; it has a value. I have a txtBody_Updated(Code As Integer) Sub
    which I run using the same code as before. However, in the new SUB it still calls txtBody = Null, when I know it is not.

    It goes through the same code as in the Form_Current SUB, but the outcome should be different. It is not, and that is because


    the db still evaluates txtBody = Null.

    This is as I said when something is placed in it. In my case a picture. A *.png picture.

    So how to get txt.Body to move from Null to anything else, but null.

    Any help appreciated. Thanks in advance.

    Respectfully,

    Lou Reed
    Attached Files Attached Files

  2. #17
    jwhite is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Dec 2012
    Location
    North Carolina
    Posts
    349
    Correct. 0 is a numerical value of 0; ZLS is a known value of an empty string. No need to find a Youtube video - it simply is what it is. I'm not splitting hairs - just advising how VBA in MS-Access works.

    What you put in the Form_Open and Form_Load event is only executed when the form is opened. What you put in the Form_Current is executed every time focus is changed to a different record.

    Had a look at your DB posted in the first message of this thread. For Control [txtBody], Control Source = "=[txtAttachment]" - this is not needed. The update to txtBody is handled for you in Control [bntBrowse]. When I used the Browse command, it correctly populated Control [txtBody]. Therefore, the If block needs to go in the code for [bntBrowse].

    There is a quandry - Control [txtAttachment] is unbound. Is it your intention not to store the referenced attachment in the table? If this is the case, then having the code in the Open, Load, or Current event is useless.

    We don't know your business requirements, so when asking for assistance it is a good idea to describe them when asking for help on a problem.
    Last edited by jwhite; 04-14-2017 at 11:52 AM. Reason: Note: This post was typed before seeing your post #16.

  3. #18
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    All I want to do is make the form frmEmail look clean. The pile of junk in the txtBody control upon initially opening the frmEmail is a step in wrong direction. The form_current

    code that was put in yesterday works. However, when I put something in txtBody control it is till invisible.

    As I said, it certainly will not go back to form_current and run the code again with the new txtBody. So where to run the code again.

    I honestly thought that I had this solved a day ago, but when I tested the control and put a picture in it, it is still null. I created a SUB that was for the updated txtBody control.

    So what do I do? It seems that changing txtBody from Null to anything but null would do the trick. It has not.

    That is my dilemma.

    I want to make look nice and pretty and it seems very confusing. What is the txtBody after something is put in it. It certainly is not null.

    Any help appreciated. Thanks in advance.

    Respectfully,

    Lou Reed

  4. #19
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    Okay, I will put it in the Browse subroutine. It still will have a txtBody value of Null.

    What is wrong with putting it in the update SUB, it txtBody control sure has been updated?

    R,

    Lou Reed

  5. #20
    jwhite is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Dec 2012
    Location
    North Carolina
    Posts
    349
    In Sub bntBrowse_Click(), add "Me.txtBody.Visible = True" after the line "Me.txtAttachment = file"

  6. #21
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    I put the original code in as you suggested in an earlier post. It works. The window is now visible as it should be when populated. Why would not an update SUB work? It seems to be along the same line
    of reasoning?

    R,

    Lou Reed

  7. #22
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    Code:
    In Sub bntBrowse_Click(), add "Me.txtBody.Visible = True" after the line "Me.txtAttachment = file"
    Now doing this saves me from having to put the five line IF-Then-Else sequence of code. So this is better.

    Thanks for your help.

    Respectfully,

    Lou Reed
    Last edited by Lou_Reed; 04-14-2017 at 12:26 PM. Reason: correction

  8. #23
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    Code:
    In Sub bntBrowse_Click(), add "Me.txtBody.Visible = True" after the line "Me.txtAttachment = file"
    Okay, That works. Why would it not work when I put in sequence if-then-else in a update SUB? After when I put something in the txtBody it certainly is updated.

    Respectfully,

    Lou Reed

  9. #24
    jwhite is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Dec 2012
    Location
    North Carolina
    Posts
    349
    I don't know what you are referring to, but now the code is where it should be.

  10. #25
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    In post #17, I created a db that used an update subroutine. I put in the standard If-Then-Else sequence of code in it. The exact same code that I put in the form_current Sub.

    It did not work. It seemed to me that this was a situation where the update event was applicable. It did not work. The criteria that I used txtBody was not changed so the If-Then_Else code. The code

    If Nz(txtBody, "") <> "" Then
    txtBody.Visible = True
    Else
    txtBody.Visible = False
    End If

    executed the same as in form_current. I thought the event of selecting something from the Browse button was an Update event so I created Sub txtBody_Update. I then put the If-then-else code sequence in the
    Sub txtBody_Update.

    It did not work!

    There is no doubt that where you said to put it is correct. We all know that in computer science there is more than one way to get something done.

    So why did my solution not m way work. Firstly, it is obvious that txtBody's value did not change that much is known.

    That that is why the Sub txtBodUpdate did not work. But why did it not change? It seems that it would. txtBody is no longer Null.

    Any help appreciated. Thanks in advance.

    Respectfully,

    Lou Reed

  11. #26
    jwhite is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Dec 2012
    Location
    North Carolina
    Posts
    349
    Lou, you are splitting hairs... Move on.

  12. #27
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    Okay, at least tell me in MS Access 2010, or any version of MS Access, there is more than one way of accomplishing something.

    At least tell me that.

    Respectfully,


    Lou Reed

  13. #28
    jwhite is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Dec 2012
    Location
    North Carolina
    Posts
    349
    Of course there are usually more than one way to resolve an issue - the ideal outcome is to choose the right one for the situation at hand.

  14. #29
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    I have one more question that I need an answer to.

    The txtbBody field starts out in cmdSend_Email_Click as Null.

    Now I assumed that once it had a value (i.e.. the user selected something to attach to the email), then the value of txtBody is no longer Null. Thus by putting it through the If-Then-Else in my Update Sub, the outcome would be to make the box visible.

    In your solution you explicitly set txtBody to visible once a something was selected in the btnBrowsing Sub.

    So it is different, but the results should be the same.

    I just assumed it was no longer Null. I tried to implicitly set it from Null, and make it visible. You explicitly set it to Visible in Browse sub.

    I made the mistake of assuming it was no longer null when the txtBody had a value. You did not, you said make it

    Me.txtBody.Visible = True.

    I said if it is not null then set it to Visible; however, mine was explicit.

    I guess my approach assumed too much.

    Respectfully,

    Lou Reed

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 5
    Last Post: 10-29-2017, 06:46 AM
  2. Replies: 0
    Last Post: 03-30-2017, 03:20 PM
  3. Attachment pop up window is not displaying
    By WithoutPause in forum Forms
    Replies: 5
    Last Post: 04-14-2014, 08:58 AM
  4. Cleaning Up Data - Need Help
    By NeedHelp in forum Access
    Replies: 2
    Last Post: 06-05-2010, 10:06 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