Dynamic field update help?

First make sure the Column Count for the Cat Combo is set to 2 and the Column Widths set to 0";1".

Second, in the GotFocus event of the Products combo use the following code:

Me.cboProduct.RowSource = "SELECT ProductID, ProductName FROM PRODUCTS WHERE CatID = " & Me.CboCat & ";"
Me.CboProduct.Requery

Make sure that the data types on your tables match up. CatID is an autonumber, right? If so, it needs to be a Long Integer in the Product table.
 
ScottGem said:
First make sure the Column Count for the Cat Combo is set to 2 and the Column Widths set to 0";1".

Second, in the GotFocus event of the Products combo use the following code:

Me.cboProduct.RowSource = "SELECT ProductID, ProductName FROM PRODUCTS WHERE CatID = " & Me.CboCat & ";"
Me.CboProduct.Requery

Make sure that the data types on your tables match up. CatID is an autonumber, right? If so, it needs to be a Long Integer in the Product table.

OK, now were close... I now get the category names to appear instead of numbers, but now I get an error "Microsoft Access can't find the macro 'Me.' when I try and choose a product.
 
Anyone know why I get this error? "Microsoft can't find the macro 'Me.' when I try and choose a Product.

If not, point me in the right direction?

Thanks!
 
The error message means that you are using the ME qualifier somewhere in error. Is there a Debug choice when you get this error? If so, what line of code is highlighted? If not, you need to to find where you have the erroneous ME.
 
Actually, the ME came from code that you told me to use in your previous post:

Originally Posted by ScottGem
"First make sure the Column Count for the Cat Combo is set to 2 and the Column Widths set to 0";1".

Second, in the GotFocus event of the Products combo use the following code:

Me.cboProduct.RowSource = "SELECT ProductID, ProductName FROM PRODUCTS WHERE CatID = " & Me.CboCat & ";"
Me.CboProduct.Requery

Make sure that the data types on your tables match up. CatID is an autonumber, right? If so, it needs to be a Long Integer in the Product table."
 
I am begining to think no one really knows how to get this to work?
 
ScottGem said:
The error message means that you are using the ME qualifier somewhere in error. Is there a Debug choice when you get this error? If so, what line of code is highlighted? If not, you need to to find where you have the erroneous ME.

Scott - getting closer, I now receive the following:

Microsoft Visual Basic - Compile Error - Method or Data member not found and when I click "Ok" the following piece of code is highlighted in "blue" near the end of my pasted in code - ".cboCategory" from the following line of code:

Me.cboProduct.RowSource = "SELECT ProductID, ProductName FROM PRODUCTS WHERE CatID = " & Me.cboCategory & ";"
 
Some of the problem seems to be that you don't really understand the environment. Every one of the errors that has confounded you stem from scope (visibility) problems.

For instance, "Me" is a shortcut that exists only in what Access calls "documents" - forms and reports - inside of things that are coded. And only when they are coded. Further, "Me" means different things depending on where it is encountered. Yet it always means the same thing. That's because it is a shortcut to the currently opened document in the Access sense of that word. I.e. an opened member of the documents collection - which can be either a form or a report.

The "parameter" bit comes about either because you have spelled something incorrectly OR the thing you named isn't visible at the time. Whenever Access has to evaluate something that it can't find, it assumes that you have named a parameter, so it asks for it. Therefore, whenever you see that kind of error message, look for the thing you named to not be open or not have the name you see in the parameter dialog box.

The issue with changing (or not changing) underlying data in a table when you used a field for lookup relates to not realizing whether the data was part of the active recordset for the form. If you are going to search for data that is in common with a lookup table and the working table you are populating, look at some of the "Combo box" or "List box" wizards. One of them includes a way to have the box look up a related record. If you look it up from the wrong table, you start changing things that you might not have wanted to change. This is where the combo box wizard can help you.

All of these things tell me that you need to find a good Access textbook. If I knew one, I'd name it - but my wife teaches this stuff and she has yet to find a book she likes.

OK, this criticism doesn't solve your problem.

Scott's instructions were fairly clear. I strongly suggest you return to the sample code that is part of this site and also use the Search feature to find more examples of "Cascading Combo Boxes" as a way to get you going. If you can find an article by Pat Hartman, you will be ahead of the game. She's good at what she does. I regret that I don't have my reference books with me right now so I can't be more specific in my suggestions.
 
Doc - I can appreciate your criticism. I know that the previous posts might have wearied many of you. This is actually my first attempt at doing anything with Access and yes, I am at an extreme disadvantage when it comes to the knowledge that most of you possess.

However, you will be happy to know that I finally after many hours of trial and error and reading over and over through these posts - got the combo boxes working as I wanted. I learn better by experience, mistakes, trying and retrying.

Thanks Scott for your help I really do appreciate it, and Doc I do currently have 3 Access books, none of which address combo boxes at all - but hey, again thanks for the suggestion.

If anyone is interested, I did use the example found at:
http://support.microsoft.com/?kbid=209576
 
Applause. My compliments on your perserverance and success.
 
Ooop's maybe I spoke too fast. The combo boxes are working fine. But, it seems I now have another problem related somewhat to them.

I will post my database so that you can have a look. I don't know if my explanation will suffice.

Whenever I choose a category and product from the combo boxes on the "Order Details Subform" - and there were other entries for this specific customer, all of their entries change to whatever I chose from the combo's.

Say they had a previous entry for carpet/biscuit (Parliament) and then I add an new entry of Joist/plywood 2X8 - their previous entry changes to my new choice also even though it's a new record for this customer.

I hope that explanation makes sense.

If not, take a look at my DB that is attached.

From the switchboard choose "Add and Order and Details" then in the "subform" add a new record by clicking the arrow to go to the next record... and then choose a category and product. You will notice that the previous record changes also?
 

Attachments

Users who are viewing this thread

Back
Top Bottom