• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

2 list boxes and sql and access

Bulldog13

Golden Member
Greets,

It s been awhile since I programmed, so I am pulling a blank here.

2 tables. We ll call them table PARENT_COMPANY and table CUSTOMER_INFO.

PARENT_COMPANY has ID (autonum) and Parent_Company_Name .

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

Ok, now.

2 list boxes, each with a table.

The user clicks the first, selects a Parent_Company_Name. I can do that.

Next the 2nd list box is populated with all of the possible Names from Customer_Info (Parent_company has multiples customers). Obviously, they are linked between PARENT_COMPANY.ID and CUSTOMER_INFO.Parent_Company.

I am doing this from within a form within access 97. So all the info I found online involved openning, connecting etc to a DB which muttled me up since I am already in the DB. I remeber there was a way to do something like this utilizing subforms and child paret type things.

But at this point I would do it in pure VBA.

Thoughts?
 
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
 
Couldn't get it going.

Can you explain the last line ?

I don t seem to have the .RecordSource property for my subform.
 
Originally posted by: Bulldog13
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
 
Form_frmCUSTOMER_INFO_sub.RecordSource......... where frmCUSTOMER_INFO_sub is the name of your subform.

Mike
 
Back
Top