2 menus, and access sql [foreign key] [customer info]

Q: Greetings,

It s a while since I programmed, so Im drawing a blank here.

2 tables. Well call them PARENT_COMPANY table and table CUSTOMER_INFO.

PARENT_COMPANY, ID (AutoNum) and Parent_Company_Name 0.

CUSTOMER_INFO Name Parent_Company and has (number). Parent_Company is a of the table PARENT_COMPANY.

Ok, now.

2 list boxes, each containing a user clicks table.

The first chooses a Parent_Company_Name. I can do that.

Next the second list is filled with all possible names Customer_Info (Parent_company customers have multiples). Of course, they are linked between PARENT_COMPANY.ID CUSTOMER_INFO.Parent_Company.

I and do this from a form in Access 1997. So all the info I found online question openning, etc connected to a DB that muttled me up because I was already in the DB. I remember there was a way to do something like this using subforms and child Paret things.

But type at this point that I would do in pure VBA.

Thoughts?


Best Answer: The source for combo box 2 should be a query, with a Where clause using the value in combo box 1, similar to this:

SELECT FRUIT
FROM FRUIT_TABLE
WHERE FRUIT_TYPE = [Combo Box 1]

And you will probably have to put something in the LostFocus event of Combo Box 1 to refresh the source for Combo Box 2.


Re:Thanks, but I did it in a slightly different way.

I ended up just using some vba.


Re:Form_frmCUSTOMER_INFO_sub.RecordSource……… where frmCUSTOMER_INFO_sub is the name of your subform.

Mike


Re:access 97

When I put a subform it doesn t seem to be named that, it is named child number number


Re:Originally posted by: guy
Couldn't get it going.

Can you explain the last line ?

I don t seem to have the .RecordSource property for my subform.

1) Which versio are you running.

Form_frmCUSTOMER_INFO_sub.RecordSource = LSQL
Instructs application to fill the form with the SQL query results generate using the LSQL variable string


Re:Couldn't get it going.

Can you explain the last line ?

I don t seem to have the .RecordSource property for my subform.


Re:Create a main form for your 1st listbox with the company names that you want to use.

Create a subform for the Customer Information.

Add the following code to the AfterUpdate event for the 1st listbox.

Dim LSQL As String

LSQL = "select * from CUSTOMER_INFO"
LSQL = LSQL & " where Parent_Company = '" & Listbox & "'"

Form_frmCUSTOMER_INFO_sub.RecordSource = LSQL

Mike


Related posts

Leave a comment

0 Comments.

Leave a Reply


click to changeSecurity Code

[ Ctrl + Enter ]