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

    Cleaning up of attachment Window

    In the file that I have attached, in frmEmail there is a window. It is a windows that is a "place holder" for any attachment that the user of the db so desires.

    He can also choose to have no attachment at all.

    Right now in that windows is full of random junk. It looks terrible.

    So how do clean that up. It is as I said only a place holder for the attachment that may come.

    How to clean?

    Respectfully,

    Lou Reed
    Attached Files Attached Files

  2. #2
    jwhite is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Dec 2012
    Location
    North Carolina
    Posts
    349
    You could in design mode set the control to .Visible = False. Then in the On Current event, if it has a value, set .Visible to True for the control; but if it doesn't set .Visible to False (use If then else end if block).

  3. #3
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    I assume this VBA code would go in the form_current Sub , in the code for frmEmail?

    Also, how do you check if the ctrl in question has a value or not?

    Respectfully,

    Lou Reed

  4. #4
    jwhite is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Dec 2012
    Location
    North Carolina
    Posts
    349
    Yes, when looking at the properties of the form, Events, Current.

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

  5. #5
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664

    What is wrong with this?

    I used the routine VBA code as follows:

    Code:
       If txtBody.Value = Null Then
            txtBody.Visible = False
         Else
            txtBody.Visible = True
         End If
    I put it in form_current Sub program. I felt that when a user opens the form frmEmail
    then this would be the first code sequence to run.

    It did not work. Please explain why. It seems as logical as the codethat you used.

    Code:
    If Nz(variablename,"") <> "" Then
        variablename.Visible = True
     Else
        variablename.Visible = False
     End If
    I saw the term <> "", it seemed unnecessarily complicated.

    I like mine. It does not work; the term txtBody is the name of the control that I was to be visible based on
    certain criteria. As I said, it did not work.

    Any help appreciated. Thanks in advance.

    Respectfully,

    Lou Reed
    Attached Files Attached Files

  6. #6
    jwhite is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Dec 2012
    Location
    North Carolina
    Posts
    349
    As you have arrow keys on the form to go from record to record back and forth, you must put it in the Form Current event, which you already have some code in. "<>" is not complicated at all - it translates to Not Equal. Before you can compare you have to account for when the variablename may equal Null (unknown value) and then compare if it equals nothing. Therefore the statement I provided you. With your example, a zero-length string (zls) would be passed as positive but ZLS is also nothing.

  7. #7
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    Okay, I understand that <> means not equal, but in mathematics =/ on top of each other means not equal. I am just not used to seeing it this way. Also, there so many ways to classify as textbox as empty, null etc. I just thought that simply

    txtBody.Value = Null

    would handle it. Where does this code go? In the form_current Sub? I assume it does, this is what you said.

    Now please explain these two sentences:

    Code:
    Before you can compare you have to account for when the variablename may equal Null (unknown value) and then compare if it equals nothing.  Therefore the statement I provided you.  With your example, a zero-length string (zls) would be passed as positive but  ZLS is also nothing.
    There seem to be so many ways of calling something empty in MS Access VBA, that I why I just chose the simplest or so I thought.

    Also, "" mean empty also?

    Any help appreciated. Thanks in advance.

    Respectfully,


    Lou Reed

  8. #8
    jwhite is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Dec 2012
    Location
    North Carolina
    Posts
    349
    Null is an Unknown value - it can't be evaluated, therefore you have to check for that before anything else. "", or Zero Length String, is a Known value which can be evaluated. Allen Browne has a great reference on this topic on his website: http://allenbrowne.com/vba-NothingEmpty.html

  9. #9
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    Okay, so you must do two things where I do only one. I do not see how this is a compound statement.

    If Nz(variablename,"") <> "" Then

    Is two things or two steps. I guess inside parenthesis are evaluated first then that could be called one step and then <> "" could be the second step. So is that what you are driving at?

    If so why not use

    Nz(variablename) <> "" Then


    instead?


    Again this is awfully long way to go just to see if something evaluates to 0.


    Respectfully,

    Lou Reed

    Respectfully,


    Lou Reed

  10. #10
    jwhite is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Dec 2012
    Location
    North Carolina
    Posts
    349
    The first part of the If first makes sure we have a value we can compare with. My statement is explicitly stating I want to return a ZLS if the variable is Null. You can also explicitly return 0.

  11. #11
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    So one cannot use

    Nz(variablename)

    instead of:

    Nz(variablename,"")

    I still do not see where mine is worse than yours. It certainly seems
    simpler.

    R,

    Lou Reed

  12. #12
    jwhite is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Dec 2012
    Location
    North Carolina
    Posts
    349
    It isn't clear in my reading whether the default to return is 0 or ZLS - it just says it will return one or the other, therefore I always make it explicit so "I" always know what is going to be returned if it is Null. finis.

  13. #13
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    I take it 0 and ZLS are not the same. Is there a YouTube video on this? I come from a very quantitative background and it just seems that we are splitting hairs in what
    the absence of anything is.

    I will use you version although I admit I do not understand it.

    Respectfully,

    Lou Reed

  14. #14
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    In the code shown below, I have put in the form_current Sub.

    Code:
    Private Sub Form_Current()
    ' Enable Send Ticket command button
    ' if meeting invite sent
    ' checkbox is not checked
         If Nz(txtBody, "") <> "" Then
            txtBody.Visible = True
         Else
            txtBody.Visible = False
         End If
       
         If Me.chkMeeting_Invite_Sent = True Then
             Me.cmdSend_Email.Enabled = False
         Else
             Me.cmdSend_Email.Enabled = True
         End If
    End Sub
    Now that takes care of the attachment window when I open frmEmail. It is has nothing, but Null in it,
    so it makes it invisible. That is the first half of the condition.


    But what about when I put something in it? It really does not become visible and this code because
    it is in form_curerent Sub and since the form is already opened there is no possibility of the code sequence
    being reread and make txtBody visible.


    That was the question that was nagging me yesterday, and now it shows up in a different scenario
    , but it is still the same question.


    This if then else code sequence is only operated when the form is opened. There once txtBody is not empty

    where is the code to make it visible?

    Any help appreciated. Thanks in advance.

    Respectfully,


    Lou Reed

  15. #15
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    I need an answer to this question as soon as possible. It really is stopping the development of the db.

    Respectfully,

    Lou Reed

Page 1 of 2 12 LastLast
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