I'm using the DLookup( ) function in a 'text box' control on my form to
look-up a value in a table depending on the value on another control (Combo
box) on the form.
The function works fine until I 'Add' a new record upon which there no
longer a value for the DLookup function and hence the word Error# is
displayed in the text box control using the DLookup function.
The access knowledge base states that when you move to a new record, the
DLookup() text boxes that update automatically will have "#Error" in them
until you enter something in the text box that the DLookup function is
referencing.
When a New record is entered, is there a way to suppress the word #Error
until the user has selected an option from my combo box?
Maybe I missed something in the knowledge base?
TIA
Set the Textbox's source in the afterUpdate event of the combobox
"Bob Lothar" <count...@hotmail.com> wrote in message
news:9jq5k1$5vj$1...@newsg1.svr.pol.co.uk...
Example: your text box might have a ControlSource like this:
=DLookup("SomeField", "SomeTable", "AField = " & [MyKeyField])
At a new record, MyKeyField has no value yet, so the 3rd argument
becomes just:
"AField = "
which is an error.
Use Nz() to solve the error, e.g.:
=DLookup("SomeField", "SomeTable", "AField = " & Nz([MyKeyField],0))
--
Perth, Western Australia
Tips for MS Access users at:
http://odyssey.apana.org.au/~abrowne
The arguments are corrrect as stated in the access knowledge base.
Which event do I use?
OnCurrent?
Allen Browne <abr...@odyssey.apana.org.au> wrote in message
news:3B60C901...@odyssey.apana.org.au...
"alt.talk.bollocks" wrote:
[snip: nothing of value]
> "abr...@odyssey.apana.org.au" wrote:
Allen Browne <abr...@odyssey.apana.org.au> wrote in message
news:3B624FF3...@odyssey.apana.org.au...
> Use a real name if you want to be taken seriously here.
>
>
> "alt.talk.bollocks" wrote:
> [snip: nothing of value]
[snip: If its not worth it, don't bother]
No that sucks too smart arse...
How about "Bob Lothar"