DLookup Default Value in form?

B

bendixen

I have reviewed online help but am still running into a problem in trying to
run this DLookup created in Expression Builder.

I am trying to create a form where, when a 'sequence number' is entered,
other text boxes such as 'emp name' in the same form are populated with a
Default Value (which can be later changed on the form when the curser is
tabbed to them).

I have a table named {tbl_projectmaster} which has all the default values
(some of which aren't correct for my use). I have a form named {frm_effort
report} which adds to a table named {tbl_effort report}. Table
{tbl_effort_report} has all the same fields as the table {tbl_projectmaster}
,plus other fields. All fields are text based as they use a combination of
numbers and letters.

The code I'm writing into the Default Value entry of the form's text box
property is =DLookup ("[sequence num]","tbl_projectmaster","[emp
name]=forms![emp name]")

There is no result in the field when I run this. The text boxes remain
empty after I enter the 'sequence number' into the first text box in this
form. I'm hoping this is an easy question for some of you, but this has me
baffled after several hours of trying to get it to work. Would someone help
me please? Thanks!
 
D

Damian S

Hi bendixen,

The problem is that the default value is set when the record is first
created, at which time, there probably isn't a value applicable.

Try using the after update event of your "Sequence Number" field to set the
values as required.

Hope this helps.

Damian.

ps: Your dlookup example will return the Sequence Number - but this is the
value you are saying you want to key in... it should be something like this:

DLookup ("[Emp Name]","tbl_projectmaster","[sequence num]=" &
me.SEQUENCENUMBERCONTROL)
 
B

bendixen

Thank you. What you wrote about the default value makes sense. I'm still
having problems when i try to use the After Update event. When I enter your
corrected code into the expression builder for After Update event, I get a
Type Mismatch error. What am I doing wrong?


Damian S said:
Hi bendixen,

The problem is that the default value is set when the record is first
created, at which time, there probably isn't a value applicable.

Try using the after update event of your "Sequence Number" field to set the
values as required.

Hope this helps.

Damian.

ps: Your dlookup example will return the Sequence Number - but this is the
value you are saying you want to key in... it should be something like this:

DLookup ("[Emp Name]","tbl_projectmaster","[sequence num]=" &
me.SEQUENCENUMBERCONTROL)


bendixen said:
I have reviewed online help but am still running into a problem in trying to
run this DLookup created in Expression Builder.

I am trying to create a form where, when a 'sequence number' is entered,
other text boxes such as 'emp name' in the same form are populated with a
Default Value (which can be later changed on the form when the curser is
tabbed to them).

I have a table named {tbl_projectmaster} which has all the default values
(some of which aren't correct for my use). I have a form named {frm_effort
report} which adds to a table named {tbl_effort report}. Table
{tbl_effort_report} has all the same fields as the table {tbl_projectmaster}
,plus other fields. All fields are text based as they use a combination of
numbers and letters.

The code I'm writing into the Default Value entry of the form's text box
property is =DLookup ("[sequence num]","tbl_projectmaster","[emp
name]=forms![emp name]")

There is no result in the field when I run this. The text boxes remain
empty after I enter the 'sequence number' into the first text box in this
form. I'm hoping this is an easy question for some of you, but this has me
baffled after several hours of trying to get it to work. Would someone help
me please? Thanks!
 

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