Form field update based off of previous field

A

Andrew Tatum

Alright. First and foremost I truly appreciate all your help recently.
I'm working on a project and this group has been a lifesaver!

I have a form that contains:

Date
CompanyID
InvoiceID
Amount

It is created off of the PaymentsReceived table. In the table, there is
a Combo box look up for CompanyID and InvoiceID.

Basically, on the form if Company 1 is selected I would want the
InvoiceID drop down box to display only Invoices that relate to
CompanyID.

Thanks guys!
 
R

Roger Carlson

These are called cascading combo boxes and in the Row Source of the second
combo box, you need to reference the first. Something like:

Select InvoiceID from PaymentsReceived where CompanyID =
forms!TheForm!Combo1

Where the form is named TheForm and the first Combo is named Combo1.

Also, in the After Update event of Combo1, you need to have something like:
Me.Combo2.Requery

On my website (www.rogersaccesslibrary.com), is a small Access database
sample called "CascadingComboBoxes.mdb" which illustrates how to do this.

--
--Roger Carlson
MS Access MVP
Access Database Samples: www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L
 
A

Andrew Tatum

Thanks!

So I have this so far:

Private Sub CompanyID_AfterUpdate()
Me!InvoiceID = Null
Me!InvoiceID.Requery
End Sub

For the second ComboBox, I have this:

SELECT PaymentsReceived.InvoiceID
FROM PaymentsReceived
WHERE
(((PaymentsReceived.CompanyID)=[forms]![PaymentsReceived]![CompanyID]));

When I then look at the form... the second drop down box is blank :(.
Any ideas?
 
H

Heather A. Hartel

Thanks!

So I have this so far:

Private Sub CompanyID_AfterUpdate()
Me!InvoiceID = Null
Me!InvoiceID.Requery
End Sub

For the second ComboBox, I have this:

SELECT PaymentsReceived.InvoiceID
FROM PaymentsReceived
WHERE
(((PaymentsReceived.CompanyID)=[forms]![PaymentsReceived]![CompanyID]));

When I then look at the form... the second drop down box is blank :(.
Any ideas?
 
A

Andrew Tatum

Just wanted to update. For some reason the subject of this message was
changed to something about a test... so I don't think anyone saw this
message....
 
R

Ron2006

Do you mean there are no selections available for the invoice box or
just that it appears empty after you have selected a company?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top