What is the VB code for looking up a value in a table?
Collapse
X
-
Code:Nz(DLookup("[fieldname in the table]", _ "table name", _ "[fieldname in the table] = " & Me.textbox control name& ""))
Comment
-
Originally posted by mseomseo: I need to know, what's the difference between Null and Zero-lenght string?
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
-
Originally posted by mseomseo: 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& ""))
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
-
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
Comment