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

Field Look-up Value

Status
Not open for further replies.

kenner

Technical User
May 23, 2000
1
CA
I have a form that has a bound field that passes it's value to a query. The query runs against a table to determine a second value. Now I want the second value to be displayed in the original form in an unbound field.<br><br>Hope I have explained it OK.<br><br>The first field on the form is a combo box and when I open the form there is a value in it, and the unbound field contains the first value returned from the query. If I change the first field's value the unbound field does not automatically update to reflect the new query value.<br><br>If I minimize the form run the query it has the proper value I want in the unbound field. I have tried combinations of &quot;me.requery&quot; for the combo box &quot;change,afterupdate, etc.&quot; with no sucess.<br><br>I guess I need some VB code to force the UB field to change. I don't know?<br><br>Can someone help?
 
Interacting with a query is clumsy<br>You could get the SQL code out of the query and put it in your form.<br>Then you could have several SQL statements that return values in sucession.<br>and easily put any of their results in different text boxes on the same form.<br>----------------------------------------------------------<br>Private Sub Command0_Click()<br>&nbsp;&nbsp;&nbsp;&nbsp;Dim db As Database, rst, rst2 As Recordset, SQL, SQL2 As String<br>&nbsp;&nbsp;&nbsp;&nbsp;Set db = CurrentDb<br>&nbsp;&nbsp;&nbsp;&nbsp;' SQL string using the combobox info.<br>&nbsp;&nbsp;&nbsp;&nbsp;SQL = &quot;SELECT * FROM Orders WHERE OrderDate &gt;= &quot; & Me!Combo1.Column(0)<br>&nbsp;&nbsp;&nbsp;&nbsp;Set rst = db.OpenRecordset(SQL)<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;Me!Text1 = rst![OrderDate]&nbsp;&nbsp;&nbsp;'set a text box to some value returned<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;' second qquery is using a value from first query<br>&nbsp;&nbsp;&nbsp;&nbsp;SQL2 = &quot;SELECT * FROM Invoices WHERE InvoiceID &gt;= &quot; & rst!Invoice<br>&nbsp;&nbsp;&nbsp;&nbsp;Set rst2 = db.OpenRecordset(SQL2)<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;Me!Text2 = rst2![Partnumber]<br><br>End Sub<br>------------------------------------<br>Basically this code is behind a button <br>So you would pick something in a combox then click this button.<br>It would run 2 SQL statements which are the same exact SQL code as was in your queries.<br>It then returns results to 2 different textboxes.<br>The second SQL statement gets data from the first i.e. Invoice. <br><br>OK <p>DougP<br><a href=mailto: dposton@universal1.com> dposton@universal1.com</a><br><a href= > </a><br> Ask me how Bar-codes can help you be more productive.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top