How to save the result of DLookup function (used in unbound text box) in a table (1 Viewer)

irslan rafique

Registered User.
Local time
Today, 18:12
Joined
Oct 17, 2014
Messages
26
I have a form based on query. On form i am retrieving data from another table using DLookup in a unbound text box. So i want to save the result of DLookup function in another field/table on same form.
Plase take out me from this problem.
Thanks
 

Minty

AWF VIP
Local time
Today, 11:12
Joined
Jul 26, 2013
Messages
10,371
If you can look it up in one form, I'm slightly baffled as to why you need to store it in another table? Why not just look it up again when you need it.

If you have to store it and the field is on your form try after updating the lookup;
me.newstoragefield = me.lookupcontrol
 

irslan rafique

Registered User.
Local time
Today, 18:12
Joined
Oct 17, 2014
Messages
26
Bro i am retrieving data from 2nd table using dlookup function in (lookup control) and storage field is a simple field from my 1st table.
As you suggested.
me.newstoragefield = me.lookupcontrol

Its not working.

Please help me. I cant explain my disappointments.

Thanks
 

Minty

AWF VIP
Local time
Today, 11:12
Joined
Jul 26, 2013
Messages
10,371
Look up control sounds like a possible problem. Can you post up the control source, or even a stripped down version of the form. Without seeing your code we are all working blind.
 

irslan rafique

Registered User.
Local time
Today, 18:12
Joined
Oct 17, 2014
Messages
26
I have a table called main with fields of:
Consignee ID, Location
One query based on table main. One form based on query.
I have 2nd table Consignees with 2 fields (Consignee ID and Location)
On Only form I have fields for Consignee ID, Location and one unbound text box. I am retrieving location from 2nd table using Dlookup function in unbound text box. So I want to save the result of this textbox in Location field.
Please help me
 

Minty

AWF VIP
Local time
Today, 11:12
Joined
Jul 26, 2013
Messages
10,371
Where are you trying to save it to? having 2 tables with the same field names is very confusing, can you not call them something different to make your code more easily understood ?
 

irslan rafique

Registered User.
Local time
Today, 18:12
Joined
Oct 17, 2014
Messages
26
Noted!
I have changed the name of the field in first main table:
Now:
I have a table called main with fields of:
Consignee ID, Zone Location

I have 2nd table (Consignees) with 2 fields :

Consignee ID and Location

Now on form I have fields for Consignee ID, Zone Location and one unbound text box. I am retrieving location from 2nd table using Dlookup function in unbound text box. So I want to save the result of this text box in Zone Location field of main table.
But what code or function will be used to save the result of Dlookup in 'Zone Location' field.
Please help me
 

Minty

AWF VIP
Local time
Today, 11:12
Joined
Jul 26, 2013
Messages
10,371
That is better, add a command button to the detail of the form and on the on click event add the following code;
Me.[zone location] = me.[unbound control name]
You would be better not to include spaces in your field names.
 

irslan rafique

Registered User.
Local time
Today, 18:12
Joined
Oct 17, 2014
Messages
26
Thank you so much.Hats Off! for your prompt help.
I cant explain my feelings.

Thanks
 

Users who are viewing this thread

Top Bottom