Populate field

G

Guest

I need help in populating a field on a form.

I have a form that queries data from one table.

Now I have a need to populate just one field
for some records. I don't want to recreate the form
by joining the two tables. Instead I would like
to populate this field with the other table using
sql. Can someone help me on this one?

Like SQL = select field1+field2 ... from table2

Thank you,
-Me
 
G

Guest

Ken,

What is wrong with the following statement?
PlanLocation = DLookup("[AREA]", "PFILE", "[FILE_NUM] = " _
& Me.[FILE_NUM])

If I give the exact FILE_NUM value it works, however
this way it doesn't work. In debug mode it does
show the value for Me.[FILE_NUM]

Thanks for your help!
-Me
 
K

Ken Snell [MVP]

Depends upon what you mean by "wrong".... what happens when you use this
DLookup expression? what do you expect to happen?

--

Ken Snell
<MS ACCESS MVP>

Me said:
Ken,

What is wrong with the following statement?
PlanLocation = DLookup("[AREA]", "PFILE", "[FILE_NUM] = " _
& Me.[FILE_NUM])

If I give the exact FILE_NUM value it works, however
this way it doesn't work. In debug mode it does
show the value for Me.[FILE_NUM]

Thanks for your help!
-Me


Ken Snell said:
Check out the DLookup function (it's described in Help file).
 
G

Guest

Ken,

I was getting error - "You aborted the operation " or something like that.

I resolved it. All I needed was to add "'" before and after [FILE_NUM].

Appreciate your help!
-Me

Ken Snell said:
Depends upon what you mean by "wrong".... what happens when you use this
DLookup expression? what do you expect to happen?

--

Ken Snell
<MS ACCESS MVP>

Me said:
Ken,

What is wrong with the following statement?
PlanLocation = DLookup("[AREA]", "PFILE", "[FILE_NUM] = " _
& Me.[FILE_NUM])

If I give the exact FILE_NUM value it works, however
this way it doesn't work. In debug mode it does
show the value for Me.[FILE_NUM]

Thanks for your help!
-Me


Ken Snell said:
Check out the DLookup function (it's described in Help file).

--

Ken Snell
<MS ACCESS MVP>

I need help in populating a field on a form.

I have a form that queries data from one table.

Now I have a need to populate just one field
for some records. I don't want to recreate the form
by joining the two tables. Instead I would like
to populate this field with the other table using
sql. Can someone help me on this one?

Like SQL = select field1+field2 ... from table2

Thank you,
-Me
 
D

DebbieG

I read somewhere that DLookup can be slow and to use SQL instead.
How would I write SQL to do the same thing as a DLookup? Such as:

strVehMake = DLookup("vehMake", "qryVehicle", "Unit = " & Me.Unit)

Thanks,
Debbie


| Check out the DLookup function (it's described in Help file).
|
| --
|
| Ken Snell
| <MS ACCESS MVP>
|
| | > I need help in populating a field on a form.
| >
| > I have a form that queries data from one table.
| >
| > Now I have a need to populate just one field
| > for some records. I don't want to recreate the form
| > by joining the two tables. Instead I would like
| > to populate this field with the other table using
| > sql. Can someone help me on this one?
| >
| > Like SQL = select field1+field2 ... from table2
| >
| > Thank you,
| > -Me
| >
|
|
 
K

Ken Snell [MVP]

When used to put a value into a control on a form, DLookup is going to be
reasonably fast for you. Where it's really slow is when you use it in a
calculated field in a query. For looking up a single value, it should be ok
for you.
 

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