What is the VB code for looking up a value in a table?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mseo
    New Member
    • Oct 2009
    • 183

    #16
    Originally posted by NeoPa
    While that's true Chris, it's one of those things that should rarely, if ever, cause a problem.

    If it's used in such a way to cause any sort of noticeable delay, then the code design is almost certainly poor. Generally it's run after an operator has intervened in some way, and compared to operator times the fraction of a second of difference that it makes is hard to notice. If it's used in such a way as to be called a number of times within such a window then the performance degradation may be noticeable. In such a situation though, I'd focus my attention on the code design rather than the Domain Aggregate functions.
    hi,
    thanks for your comment
    this code, I have used it many times and it works fine, without any delay

    Comment

    • mseo
      New Member
      • Oct 2009
      • 183

      #17
      ok, Neopa,I am completely agree with you and munkee
      I am wrong
      I need to know, what's the difference between Null and Zero-lenght string?

      Comment

      • munkee
        Contributor
        • Feb 2010
        • 374

        #18
        null has no value whereas zero length has been assigned a "blank" value

        Comment

        • mseo
          New Member
          • Oct 2009
          • 183

          #19
          Originally posted by NeoPa
          I've never seen any evidence of that MSEO. In what way have you found there to be a problem? Is this a case of not handling the returned result correctly perhaps?
          so why would I use something like this with datatype number fields:
          Code:
          Nz(DLookup("[fieldname in the table]", _ 
                     "table name", _ 
                     "[fieldname in the table] = " & Me.textbox control name& ""))
          Last edited by NeoPa; Jul 25 '10, 04:58 PM. Reason: Please use the [CODE] tags provided

          Comment

          • NeoPa
            Recognized Expert Moderator MVP
            • Oct 2006
            • 32633

            #20
            Originally posted by mseo
            mseo: I need to know, what's the difference between Null and Zero-lenght string?
            Null is not a value as such at all. It is an indicator of an absence of a value.

            An empty string, on the other hand, is a string value that simply has no characters in it. Strings can be of any length from 0 characters upwards, to the upper limit. Of the VBA variable types (excluding any object types), only Variant can possibly hold a Null, as standard variables are designed to hold values of a specific type only and Null is none of those.

            I hope this clarifies things for you somewhat :)

            Comment

            • NeoPa
              Recognized Expert Moderator MVP
              • Oct 2006
              • 32633

              #21
              Originally posted by mseo
              mseo: so why would I use something like this with datatype number fields:
              Code:
              Nz(DLookup("[fieldname in the table]", _ 
                         "table name", _ 
                         "[fieldname in the table] = " & Me.textbox control name& ""))
              Good question. That's code that cannot possibly compile.

              If you are asking why the use of Nz() for a number field then that's a different story.

              First of all, the Nz() is applied to the DLookup() call and not the field. If you check the Help system for DLookup() you'll see it returns a Null if nothing is found.

              Secondly, fields are not VBA variables. They are designed to have the possibility of containing Nulls. This is configurable in the design of your table fields, but the possibility is there.

              Comment

              • NeoPa
                Recognized Expert Moderator MVP
                • Oct 2006
                • 32633

                #22
                A new, and unrelated question was asked in this thread by the OP which has now been moved to Clear Error Message from TextBox. This is against our rules and I'd ask that you create new threads for your questions please.

                Comment

                Working...