Sabtu, 09 Juli 2011

[MS_AccessPros] Synchronized combo boxes on forms

 

Hello, I am creating a time tracking database for my department at work. I use Access 2007 and my experience level is beginner. I am having trouble synchronizing the customer and product combo boxes on my main data entry form. I want the selection in the customer combo to limit the choices in the product combo. When adding a new record, selecting a customer from the dropdown gives the error message: "The value you entered isn't valid for this field."

I am using the suggestions and code from this website:
http://msdn.microsoft.com/en-us/library/bb404901%28v=office.12%29.aspx

I put a zipped copy of my database in a folder named "PTS Time Tool" in the "Assistance Needed" folder. The file is named "TimeTool_2"

To see the error, pull up the database and click the "Add Time Records" button. Login with username=Griffis and password=staff1. This will bring up the data entry screen. When adding a new record, selecting a customer gives the error message.

The code for the customer combo "after update" event is below. The error occurs in the last line. I am not familiar with VB and just copy and paste what I need from other sources and do my best to figure it out. Keep in mind that my test data has ten customers, but only the first five need products. Customers six through ten do not need to show a product in the dropdown.

Private Sub cboCustomer_AfterUpdate()
Me.cboProduct.RowSource = "SELECT Product FROM" & _
" TblProduct WHERE Customer = " & _
Me.cboCustomer & _
" ORDER BY Product"

Me.cboProduct = Me.cboProduct.ItemData(0)

Thanks,
Brad

__._,_.___
Recent Activity:
.

__,_._,___

Tidak ada komentar:

Posting Komentar