Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Moving DLookup results on form to a text box bound to a table 2

Status
Not open for further replies.

blondie41

Technical User
Dec 13, 2004
14
US
I have found many answers to this problem, but cannot get any to work. I hope someone can offer some help. I have a form with a text field that performs a DLookup from a query(txt1). That part works great.

However, I need to have the data bound back to the table that the form is bound to. So, the answer appears to be; creating an additional text box (txt2). Then, go back to txt1, go to AfterUpdate and entering me.txt2 = me.txt1.

I have tried doing this with no success. Nothing appears in Txt2 (therefore nothing populates the table it is bound to). Please help me figure this out - what am I missing?
 
It is generally consider bad practice to store a value that can be calculated on the fly. If you really have a good reason, based on your naming, txt2 should have a control source of a field from the record source of the form.

It txt1 contains a DLookup() expression, it will never trigger an "AfterUpdate" event. You must have some other control or controls that should fire the AfterUpdate to push the calculated value int txt2.

You might need to tell us more about your calculation, DLookup(), control sources, etc.

Duane
Hook'D on Access
MS Access MVP
 
Thank you for your help. The end goal of this database is to create a table of "work assignments" so yes, I do need to store this value in the table.

txt2 does have a control source back to the table.

txt1 does contain the DLookup expression and works well. You say I need to have another control or controls that should fire the AfterUpdate. Can you explain or give examples of how to do this?

As far as additional information...]
The query that DLookup references is a parameter query that uses combo boxes on the form to fill the parameters. It only returns one value, and that is the one that populates txt1.

The form generates a unique ID that creates the unique "work assignment".

I need to move the data to tx2 so that it can then be bound back to table.

Any help is very appreciated.

 
In the BeforeUpdate event procedure of the form:
Me!txt2 = Me!txt1

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks for the answer, but it is still not working. I hate being "that person", but I forgot to explain how I got the DLookup to work in the textbox. I created a command button and added me.refresh which is how txt1 is populated. Could this be part of the problem?

 
but it is still not working
Did you try my suggestion timestamped 30 Jan 12 8:33 ?
 
Yes - I tried it. It does not work. Nothing populates txt2.
 
Can we assume the form has a record source?
Can you respond to "You might need to tell us more about your calculation, DLookup(), control sources, etc."?

If someone makes a suggestion such as PHV's, it is proper to reply whether or not it works and/or the results. We shouldn't have to ask.

Duane
Hook'D on Access
MS Access MVP
 
Sorry - I thought when I said "it is still not working" that was enough. Please excuse me for not knowing the proper way to write it.

I do appreciate the help, but I am really struggling...

The form is bound to a table - so I assume that would be considered the record source. I am using the form as a sort of "entry form"..the user goes through 3 comboboxes and those feed the query where txt1 does the DLookup and returns the value for txt 1. However, in order to get txt 1 to populate, I have created a command button that performs me.refresh. This works great. However, no matter how many things I try, I cannot get txt1 to populate txt2 (which is bound back to the table).

Is that enough information?
 
I have created a command button that performs me.refresh
So, you may put this code after the refresh:
Me!txt2 = Me!txt1

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thank you so much. I cannot even tell you how frustrated I have been for HOURS and HOURS. I swear I tried this exact idea and it did not work. However, I started from scratch and it works like a champ! Sometimes you just need to slow down, ask for help and take a deep breath. Bless You!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top