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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automated returns in fields

Status
Not open for further replies.

esu4edp

Technical User
Feb 15, 2000
59
US
How do I get a value to automaticly go in to a field by what is put in another field. <br>
<br>
I have a database with 3 tables right now. The first table is my clients. It contains client#, address, phone#, etc.<br>
<br>
The second table is my invoice table. It contains the client#, invoice#, date, amount, paid (yes/no), correction needed (yes/no), etc.<br>
<br>
The client# in table 1 is linked to table 2.<br>
<br>
This third table is where I enter any corrections to original invoices. <br>
<br>
In the corrections table the first field is the client# and I have a drop-down on it with a query to only pull down invoice that have a correction check-boxed in the invoice table. This way only the invoices that need correcting come up.<br>
<br>
Once I choose which invoice a correction is being done to. I want my other fields(old invoice#, old amount, etc. to automaticly place this information in those appropriate fields. <br>
<br>
Does this sound confusing?<br>
<br>
Craig<br>
<A HREF="mailto:esu4edp@netpluscom.com">esu4edp@netpluscom.com</A>
 
Well first off use the &quot;After_update&quot; Event so when you leave the field it trips that event.<br>
Then in that event Sub have code like <br>
Private Sub Text10_AfterUpdate()<br>
Me![Field-To-Update] = Me![Field-To-Read-From]<br>
End Sub<br>
Now to add code to an event click on your textbox and open properties (&quot;ALL&quot; TAB) then look way down to find &quot;After_Update.......&quot;<br>
Click in the white space next to it. Click the little black down arrow and pick &quot;Event Procedure&quot;. Then click the 3 dots button this will bring up the code window.<br>
It (Access) will add the &quot;Sub and &quot;End Sub&quot; lines for you<br>
Just copy and paste the &quot;me!&quot; line only leave the Sub... and END sub it creates alone.<br>
Now there is one issue with &quot;After update&quot; it only trips that event if you update the texbox.<br>
So &quot;On_Exit&quot; might be better a choice. It trips every time you leave the box. But same procedure above applies, same exact code etc.<br>
<p> DougP<br><a href=mailto: dposton@universal1.com> dposton@universal1.com</a><br><a href= > </a><br>
 
If I understand your problem correctly, an easy way to handle this is to create a form based on Invoices, and use the subform wizard to create a subform based on InvoiceCorrections. <br>
<br>
When you want to see all the invoices, with corrections, for a single client, you can use Access's Filter by Form feature (on the toolbar).<br>
<br>
An important note, the corrections table should not include Client ID. It should contain InvoiceID only. The reason is that the correction is related to the Invoice. The invoice is related to the Client. If you put ClientID in the Corrections table you are duplicating data. This violates relational Db design principles which means you'll end up in hot water sooner or later.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top