"#Name?" In Text Box

M

MikeC

I have just added a bound text box to a form. The data type is text. The
"Default Value" property has been set to:

"=(Select [Desk] From [qryUserDesk])".

This query correctly returns a distinct value that I want to use as the
default value for any new records. Whenever I attempt to add a new record,
"#Name?" appears in the text box. Is there something wrong with my syntax?

I'm using Access 2002 SP3 with Windows XP Home Edition SP2.
 
M

MikeC

I just tried using the below code in the form's Open event procedure:

Me!txtPaymentDesk.DefaultValue = DLookup("[Desk]", "[qryUserDesk]")

The "#Name?" still appeared when I attempted to add a new record, so I ran
the above code through the debugger and verified that DLookup is returning a
valid string value.

I even removed the text box control and re-added it from the field list (and
renamed it as txtPaymentDesk) just to be certain there was nothing wrong
with the control itself.

The "#Name?" still appears in the text box when adding a new record. The
data for the bound field displays correctly for any existing records.

Just as a simple test, I entered "Test" as the Default Value in the property
sheet and verified that a simple constant string does work correctly. I
just can't figure out why a programmatically-supplied string does not seem
to be working.
 
M

MikeC

The additional concatenation of """" on both ends fixed it:

Me!txtPaymentDesk.DefaultValue = """" & DLookup("[Desk]",
"[qryUserDesk]") & """"



MikeC said:
I just tried using the below code in the form's Open event procedure:

Me!txtPaymentDesk.DefaultValue = DLookup("[Desk]", "[qryUserDesk]")

The "#Name?" still appeared when I attempted to add a new record, so I ran
the above code through the debugger and verified that DLookup is returning
a valid string value.

I even removed the text box control and re-added it from the field list
(and renamed it as txtPaymentDesk) just to be certain there was nothing
wrong with the control itself.

The "#Name?" still appears in the text box when adding a new record. The
data for the bound field displays correctly for any existing records.

Just as a simple test, I entered "Test" as the Default Value in the
property sheet and verified that a simple constant string does work
correctly. I just can't figure out why a programmatically-supplied string
does not seem to be working.


MikeC said:
I have just added a bound text box to a form. The data type is text. The
"Default Value" property has been set to:

"=(Select [Desk] From [qryUserDesk])".

This query correctly returns a distinct value that I want to use as the
default value for any new records. Whenever I attempt to add a new
record, "#Name?" appears in the text box. Is there something wrong with
my syntax?

I'm using Access 2002 SP3 with Windows XP Home Edition SP2.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top