Populating a TextBox on a subform based on the value of another co

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I would like to automatically update the value of TextBox2 oa a subform after
entering a value in TextBox1. The subform is continuous (multiple lines) and
my attempts to used DLookup update the values for all th records on the
subform.

The subform looks like

InvoiceID..........AinvoiceAmount
InvoiceID..........AinvoiceAmount
InvoiceID..........AinvoiceAmount
InvoiceID..........AinvoiceAmount
InvoiceID..........AinvoiceAmount


Thanks
 
Sorry, but you need to give us more information. You posted an example of
the subform's "display", but didn't tell us which is TextBox2? And what do
you want to display in that textbox? What are you typing into TextBox1? Etc
etc. etc.
 
Ken -In TextBox1 I enter an invoice number (integer) and I expect TextBox2
to be populated by the value of InvoiceAmount, corresponding to the Invoice
number, from QryHours, a query I have defined.

The following example may give you a better understanding of what I am
trying to accomplish:

Select InvoiceAmount
From QryHours
Where Q.Invoice = F.Invoice

Q.Invoice = Invoice number used as a criteria on the query
F.Invoice = The Invoice number entered into textBox1 on the form.


Thanks for the help
 
I'm still not clear where TextBox1 is located (on the main form? In the
subform?), nor how the query that you just posted has any bearing to
TextBox2.

Is the query that you posted the recordsource of the form that is serving as
the subform? Is it your intent that F.Invoice should be replaced by some
reference to TextBox1?

Please provide more information about the form's and subform's setups.
 
Here we go. I have a form. FrmPay, with two controls on it: CheckNumber and
PayDate. The source for both controls on the main form is TblPay. On the
Subform, FrmPaySub, I have three controls: InvoiceID, InvoiceAmount and
Amount. The control source for InvoiceID and Amount is TblPayDetails.
InvoiceAmount is unbound. Operationally speaking, I enter a Check # and Date
on the main form and then enter one or more detail lines on the subform. I
will Enter the InvoiceID and Amount, constituting the payment, and would like
for the application to automatically populate the InvoiceAmount control on
the subform based on the value entered into InvoiceID. the source for the
value of InvoiceAmount is the QryHours query. The main form and subform are
linked through a common PayID value which is not displayed on the forms

I hope this gives you sufficient details and thanks again for the help.
 
I think the best approach will be to use an expression as the Control Source
for the InvoiceAmount control. This expression would use the DLookup
function to get the InvoiceAmount value from the table. I'm not sure if I
have the correct names in the following expression, so you may need to
change them:

=DLookup("InvoiceAmount", "tblInvoices", "InvoiceID=" & [InvoiceID])

--

Ken Snell
<MS ACCESS MVP>
 
Ken - Thanks for all your previous help. The DLookup function does return
the value I am looking for but the problem is that my form is a continuous
one and I need to limit the value returned by DLookup to individual records.
As is, the Dlookup function changes the value of InvoiceAmount for all
records on the form.

strFilter = "InvoiceID = " & Me!InvoiceID
Me!InvoiceAmount = DLookup("InvoiceAmount", "TblInvoices", strFilter)



Ken Snell said:
I think the best approach will be to use an expression as the Control Source
for the InvoiceAmount control. This expression would use the DLookup
function to get the InvoiceAmount value from the table. I'm not sure if I
have the correct names in the following expression, so you may need to
change them:

=DLookup("InvoiceAmount", "tblInvoices", "InvoiceID=" & [InvoiceID])

--

Ken Snell
<MS ACCESS MVP>


Rafi said:
Here we go. I have a form. FrmPay, with two controls on it: CheckNumber
and
PayDate. The source for both controls on the main form is TblPay. On the
Subform, FrmPaySub, I have three controls: InvoiceID, InvoiceAmount and
Amount. The control source for InvoiceID and Amount is TblPayDetails.
InvoiceAmount is unbound. Operationally speaking, I enter a Check # and
Date
on the main form and then enter one or more detail lines on the subform.
I
will Enter the InvoiceID and Amount, constituting the payment, and would
like
for the application to automatically populate the InvoiceAmount control on
the subform based on the value entered into InvoiceID. the source for the
value of InvoiceAmount is the QryHours query. The main form and subform
are
linked through a common PayID value which is not displayed on the forms

I hope this gives you sufficient details and thanks again for the help.
 
Back
Top