Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Front End
Message
De
20/08/2001 12:17:22
 
 
À
20/08/2001 11:42:27
Information générale
Forum:
Visual Basic
Catégorie:
Bases de données DAO/RDO/ODBC/ADO
Titre:
Divers
Thread ID:
00546017
Message ID:
00546276
Vues:
21
This message has been marked as the solution to the initial question of the thread.
>First, I really appreciate your help. I have looked at this from so many differnt ways, I cant see the forest, for the trees in the way.
>
>If you could expand on this a little more, I think I will have it.
>
>1)When a user opens the "Company" form. All he gets is a listing of the Company table, with edit/add/delete capabilities.(This is working now using an ADODC and text boxes).
>
>2)When the user opens the "Division" form, he will have to select the correct Company, then it should show all Divisions currently referenced to that Company, and give him the ability to edit/add/delete only the Division table.
>
>(This is where I get lost)
>3)When the user opens the "Department" form, he will have to select from the Company, then from the Divisions associated with the selected Company. And he will need the ability to edit/add/delete only from the Deptartment table.
>
>4)etc.............
>
>The tables are
>Company:CompanyID,Company_Name
> Division:DivisionID, Division_Name, CompanyID
> Department:DepartmentID, Department_Name, DivisionID
> Extension:ExtID, Ext_Name, DepartmentID

Assuming that you have comboboxes where the user selects the Company-Division and using the separate recordsets approach you would have something like this on your code (syntax may not be correct, error checking not included):
Form_Load:
   Set rsCompany = New ADODB.Recordset
   Set rsDivision = New ADODB.Recordset
   rsCompany.Open "Select * From Company", OpenConnection
   rsDivision.Open "Select * From Division", OpenConnection
   Do While Not rsCompany.EOF
      cmbCompany.AddItem rsCompany("Company_Name").Value
      cmbCompany.ItemData(cmbCompany.NewIndex) = rsCompany("CompanyID").Value
      rsCompany.MoveNext
   Loop
   ...
cmbCompany_DropDown or cmbCompany_Click:
   If cmbCompany.ListIndex<>-1 Then 'user has made a selection
      rsDivision.Filter = "CompanyID=" & CStr(cmbCompany.ItemData(cmbCompany.ListIndex))
      Do While Not rsDivision.EOF
         cmbDivision.AddItem 'etc. (same type of code as cmbCompany)
      Loop
   End if
Where the vars for the recordsets are form-level vars that have been dimensioned in the Form_Load. Basically when the user selects a company the rsDivision will be filtered on the selected company ID and the cmbDivision will only show the pertinent company. Same for the next form but with an additional combobox for department.

Hope this helps.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform