Dlookup #Name?

George-Bowyer

Registered User.
Local time
Today, 04:44
Joined
Dec 21, 2012
Messages
178
Can someone please tell me where I am going wrong here? I just can't see it and it's driving me nuts.

I have an unbound text box [txtDualDefault], format = Currency, on a bound form.

I am trying to set its default value on opening as the value set in my default values table (so that users can permanently change the default value if they wish).

The default amount is in the "fldDefaultCurrency" currency field in "tblDefaultValues" (which also has default date, number and text fields available for use, as well as "fldTableName" and "fldControl" and the MasterKey "DefaultID")

This is the expression that I am using in txtDualDefault's "default value" setting:

DLookUp("[fldDefaultCurrency]","[tblDefaultValues]","[DefaultID] = 1")

All I get in the field is "#Name?"


I have tried it with and without = at the front, with and without square brackets and with [DefaultID] =" & 1 at the end.


Nothing seems to work, and I just can't work out why...
 
Oh my God!

I've spent hours agonising over this - before I posted this message and gave up.


I then went off and changed the colour of another control and now it's working???


I mean, good and everything - but wtaf? Talk about gremlins...
 
remove the [] on the field, Table parts they are not needed and could cause you problems
 
remove the [] on the field, Table parts they are not needed and could cause you problems

If I change it and it stops working, after I have jumped off the roof, I will come and haunt you... :eek:
 
If I change it and it stops working, after I have jumped off the roof, I will come and haunt you... :eek:
We need a laughing emoji! :D

Happens to the best of us, code not working. Wander in another direction and then WHAT? it starts working again. When it does happen I sometimes find that running *Compact and Repair* chases the gremlins away.
 
If I change it and it stops working, after I have jumped off the roof, I will come and haunt you... :eek:


How many records are going to be in the table if only one I.E. a preferences/setting table which normally only has one record then you can use


DLookUp("FieldName","TableName")



It will display the first record it finds


and lol
 
FWIW, I have seen this happen due to unsaved design changes and switching to form view, be they in the recordsource or the form itself.
 
Something like that happened to me when I compacted a backend and didn't compact the front end all manor of wierd things happen.


I have started on the controls part of my Example with DLookup as a lot of people have problems with that function please note it's a work in progress but take a look at the image
 

Attachments

  • 2019-01-06 (2).png
    2019-01-06 (2).png
    64.2 KB · Views: 89
Last edited:

Users who are viewing this thread

Back
Top Bottom