Please use speaker notes for additional information!

Slides:



Advertisements
Similar presentations
Internal connection and introduction to shape language Please use speaker notes for additional information.
Advertisements

VBA Modules, Functions, Variables, and Constants
ActiveX Data Object ISYS 562. ADO An ActiveX control ActiveX is build upon COM, a contract that defines a standard interface by which objects communicate.
Using ADO Programmatically The Connection Object, Command Object, and Recordset Object.
Using Objects and Properties
Programming the RecordSet Object
Using ADO Programmatically The Connection Object and the Command Object.
CIS 451: ASP Recordsets Dr. Ralph D. Westfall May, 2002.
To type the VB code behind the command button (named cmdPush), Double-Click on the Push Me (caption) command button As a result the Visual Basic Code Window.
Introduction to Class Modules Please use speaker notes for additional information!
Visual Basic Fundamental Concepts. Integrated Development Enviroment Generates startup form for new project on which to place controls. Features toolbox.
Chapter 11 Introduction to Database Processing. Class 11: Database Processing Use a Visual Studio Wizard to establish a database connection used to load.
Introduction to ADO By David R. Stevenson Consulting Software Engineer ABB Automation.
InvEasy (Project1) Please use speaker notes for additional information!
Break Processing Please use speaker notes for additional information!
McGraw-Hill/Irwin Programming in Visual Basic 6.0 © 2002 The McGraw-Hill Companies, Inc. All rights reserved. Update Edition Chapter 11 Accessing Database.
Numeric Variables Visual Basic for Applications 6.
Programming Examples to Accompany Structure Topic Please use speaker notes for additional information!
ADO 2.5 Kamaljit Bath, Program Manager Data Access Group.
Array - adding to array at run time Please see speaker notes for additional information!
Lecture Note 10: Simple Database Techniques. Introduction –Database System –Access, SQL Server and others. –Microsoft Access - Interacting with this databases.
Visual Basic ADO Programming 56:150 Information System Design.
MDI with Menu Please use speaker notes for additional information!
Random Files Please see speaker notes for additional information!
CS285 Visual Basic 2 Department of Computing UniS 1 Statements in Visual Basic A statement is the fundamental syntactical element of a program smallest.
ActiveX Data Objects (ADO) is Microsoft’s latest database object model. The goal of ADO is to allow VB developers to use a standard set of objects to refer.
When I want to work with SQL, I start off as if I am doing a regular query.
Notes on ADO from other projects Please use speaker notes for additional information!
Two Forms Please use speaker notes for additional information!
Class Builder Tutorial Presented By- Amit Singh & Sylendra Prasad.
Visual Basic for Application - Microsoft Access 2003 Programming applications using Objects.
1.  Introduction  The Benefits of the Report Writer Module ◦ For Detail and Summary Printing ◦ For Control Break Processing ◦ For Printing Headings.
Pay Example (PFirst98) Please use speaker notes for additional information!
Visual Basic I/O Programs (ProjRead1, ProjRead2, ProjWrite1, ProjPay) Please use speaker notes for additional information!
1 Chapter 10 – Database Management 10.1 An Introduction to Databases 10.2 Editing and Designing Databases.
More on Primary and Foreign Keys Please see speaker notes for additional information!
ADO ActiveX Data Object. ActiveX Data Objects (ADO) is Microsoft’s latest database object model. The goal of ADO is to allow VB developers to use a standard.
Relational Database in Access Student System As always please use speaker notes!
Understanding Visual Basic Fundamentals CHAPTER 13 Understanding Visual Basic Fundamentals.
Source = Table rsObject.Open tablename, Connection Object, CursorType, LockType, adCmdTable Source = Stored Procedure rsObject.Open stored procedure name,
Using a Database Access97 Please use speaker notes for additional information!
Computer Login And Portal Access. Step One: Activation  Why is this important  Only way you can login to computers on campus  is the best.
1 ADO Activex Data Objects. 2 ADO ADO allows users to access data easily from many existing databases (such as Access or Paradox) From ODBC compliant.
Unbound data fields, find, filter etc. using Data Environment Please use speaker notes for additional information!
I am using Visual Basic 6 for this class. If you want to use a different version, please contact me. Thanks!
More Visual Basic Code: if-then-else, for loops Controls: Multiple forms, List Boxes, Radio buttons, frames,
ADO and DataList, DataCombo and DataGrid Controls Please use speaker notes for additional information!
 2 Data Object Library approaches ◦ DAO (Data Access Objects)  Original access strategy (up to VB6)  Closely linked to MS Access ◦ ADO (ActiveX Data.
Visual Basic - Break Processing
Processing multiple files
ADO VBA Programming in Access
Find, filter etc with connection to Access code internally
Data Environment and Grouped Report
ActiveX Data Objects (ADO)
INT213 Updating the Database.
Spreadsheet-Based Decision Support Systems
CONTENT MANAGEMENT SYSTEM CSIR-NISCAIR, New Delhi
Please use speaker notes for additional information!
Multi-host Internet Access Portal (MIAP) Enhancement Guide
Department Array in Visual Basic
Week 3. criteria must be true..
Introduction to Views and Reports
Report using ADO connection
CHAPTER 17 The Report Writer Module
Please use speaker notes for additional information!
If statements (Inven1, Inven2, Inven2a, Inven3, Inven3a)
Please use speaker notes for additional information!
Working With Databases
Using screens and adding two numbers - addda.cbl
Please see speaker notes for additional information!
Presentation transcript:

Please use speaker notes for additional information! Shape Try Examples Please use speaker notes for additional information! This slide presentation has some experiments with the shape language.

PrStuHier.vbp (Try2) This is try 2 - it accomplishes the same thing that the previous sample does but the connection is internal.

With flxStuHier PrStuHier.vbp (Try2) Set .DataSource = rsStudent00 .RowHeight(0) = 0 .ColHeader(0) = flexColHeaderOn .ColHeaderCaption(0, 1) = "Stu ID#" .ColWidth(1, 0) = 650 .ColHeaderCaption(0, 2) = "Name" .ColWidth(2, 0) = 1800 .ColHeaderCaption(0, 3) = "City" .ColHeader(1) = flexColHeaderOn .ColWidth(4, 0) = 0 .ColHeaderCaption(1, 0) = "Maj Cd" .ColWidth(0, 1) = 600 .ColHeaderCaption(1, 1) = "Major Name" .ColWidth(1, 1) = 1800 .ColHeaderCaption(1, 2) = "Major Advisor" .ColWidth(2, 1) = 1800 .ColHeader(2) = flexColHeaderOn .ColWidth(0, 2) = 0 .ColHeaderCaption(2, 1) = "Course Cd" .ColHeaderCaption(2, 2) = "Sem. Taken" .ColHeaderCaption(2, 3) = "Grade" End With The set up of the hierarchy flex grid is done internally. The band information is not available on the property pages because of this. Compare the code and property pages to the example in the slide show that introduced the shape language. This code is at the bottom of Form_Load.

PrStuHier.vbp (Try2) As you can see, the text boxes are not bound to the data through the properties.

Dim comStuHier As ADODB.Connection Dim rsStudent00 As ADODB.Recordset Dim StuCoursesInfo As ADODB.Recordset Dim MajorInfo As ADODB.Recordset Dim msgstr As String Private Sub Form_Load() Dim DBPath As String DBPath = App.Path If Right(DBPath, 1) <> "\" Then DBPath = DBPath & "\" End If DBPath = DBPath & "studentrel00.mdb" Set comStuHier = New ADODB.Connection With comStuHier .ConnectionString = "Provider = MSDataShape;" & _ "Data Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Persist Security Info=False;" & _ "Data Source=" & DBPath .Open End With The Form_Load has a connection string that includes the MSDataShape as Provider. This is required when the shape language is used to establish the recordset.

Set rsStudent00 = New ADODB.Recordset Dim SQLCmd As String SQLCmd = "SHAPE {SELECT * FROM student00} AS Student00 " & _ "APPEND ({SELECT * FROM major00} AS Major00 " & _ "RELATE 'majorcode' TO 'majorcode') AS Major00, " & _ "({SELECT * FROM stucourse00} AS StuCourses00 " & _ "RELATE 'studentidno' TO 'studentidno') AS StuCourses00" SQLCmd = "SHAPE {SELECT studentidno, name, city, majorcode FROM student00} AS Student00 " & _ "APPEND ({SELECT majorcode, majorname, advisor FROM major00} AS Major00 " & _ With rsStudent00 .CursorLocation = adUseClient .CursorType = adOpenDynamic .LockType = adLockOptimistic .Open SQLCmd, comStuHier, , , adCmdText End With Set MajorInfo = rsStudent00.Fields("Major00").Value Set StuCoursesInfo = rsStudent00.Fields("StuCourses00").Value Set txtstudentidno.DataSource = rsStudent00 Set txtname.DataSource = rsStudent00 Set txtmajorcode.DataSource = rsStudent00 Set txtmajorname.DataSource = MajorInfo With dgdCourses Set .DataSource = StuCoursesInfo .Columns(0).Caption = "Stu ID #" .Columns(1).Caption = "Crs Cd" .Columns(2).Caption = "Semester" .Columns(3).Caption = "Grade" .Refresh Rsstudent00 is now opened with SQLCmd which is text. MajorInfo is the rsStudent00 fields dealing with Major00. This is where txtmajorname comes from. The SHAPE language is used to SELECT the major data source and then APPEND and RELATE the rest of the data. In this case the student has both the major and the stucourses related to it. There are two versions of the SHAPE, one using all of the fields from student00 and one taking just four fields from student00. Since both shape commands are assigned to SQLCmd, the second one is the one that is executed. This is the information from StuCoursesInfo. It is put into a data grid.

PrStuHier.vbp (Try3) In Try3, the hierarchy flex grid is also shown on a second form. Therefore the bas module is used for the connection and the recordset.

PrStuHier.vbp (Try3) Private Sub cmdSeeForm_Click() Me.Hide frmStuHierInd.Show End Sub Private Sub Form_Load() With flxStuHierX Set .DataSource = rsStudent00 .RowHeight(0) = 0 .ColHeader(0) = flexColHeaderOn .ColHeaderCaption(0, 1) = "Stu ID#" .ColWidth(1, 0) = 650 .ColHeaderCaption(0, 2) = "Name" .ColWidth(2, 0) = 1800 .ColHeaderCaption(0, 3) = "City" .ColHeader(1) = flexColHeaderOn .ColWidth(4, 0) = 0 .ColHeaderCaption(1, 0) = "Maj Cd" .ColWidth(0, 1) = 600 .ColHeaderCaption(1, 1) = "Major Name" .ColWidth(1, 1) = 1800 .ColHeaderCaption(1, 2) = "Major Advisor" .ColWidth(2, 1) = 1800 .ColHeader(2) = flexColHeaderOn .ColWidth(0, 2) = 0 .ColHeaderCaption(2, 1) = "Course Cd" .ColHeaderCaption(2, 2) = "Sem. Taken" .ColHeaderCaption(2, 3) = "Grade" End With Private Sub Form_Unload(Cancel As Integer) This shows the code used in the form that shows only the grid. The recordset used was public in the module and is therefore available to this form.

PrStuHier.vbp (Try7) This shows the output which is by course and includes information about the student and their major and their courses.

PrStuHier.vbp (Try7) This shows the data environment and the resulting shape language statement that resulted. The Data Environment can be used to develop the code and then you can select it and use Ctrl+C to copy and paste it into your VB code and on the notepad to save etc. This statement puts the coursecode at the beginning and then shows students with their major and student courses.

PrStuHier.vbp (Try7) The first command in the connection is course where all of the courses information is taken and the data is being ordered by coursecd.

PrStuHier.vbp (Try7) The problem that was confronted is that one student can take the same course twice so we set up a special link which selects DISTINCT coursecd and studentidno from student00 and puts it in order by coursecd and studentidno. The things beneath at the next level will relate to this link and thereby to either coursecd or studentidno.

PrStuHier.vbp (Try7) This shows the link of Students to CrsStuLnk based on studentidno.

PrStuHier.vbp (Try7) As you can see major is under students and relates directly to student. The relationship is based on majorcode.

PrStuHier.vbp (Try7) The stuCrsData is linked to the CrsStuLnk based on both the coursecd and the studentidno.

PrStuHier.vbp (Try7) Note the bands that correspond to the data environment.

PrStuHier.vbp (Try7) Private Sub Form_Load() With MSHFlexGrid1 .RowHeight(0) = 0 .ColHeader(0) = flexColHeaderOn .ColWidth(1, 0) = 650 .ColHeaderCaption(0, 1) = "Crs Cd" .ColWidth(2, 0) = 2500 .ColHeaderCaption(0, 2) = "Course" .ColWidth(3, 0) = 650 .ColHeaderCaption(0, 3) = "Credits" .ColWidth(0, 1) = 0 .ColWidth(1, 1) = 0 .ColHeaderCaption(2, 0) = "Stu ID#" .ColWidth(1, 2) = 1800 .ColHeaderCaption(2, 1) = "Student Name" .ColWidth(2, 2) = 650 .ColHeaderCaption(2, 2) = "Maj Cd" .ColWidth(0, 3) = 0 .ColWidth(1, 3) = 1800 .ColHeaderCaption(3, 1) = "Major" .ColWidth(2, 3) = 1800 .ColHeaderCaption(3, 2) = "Advisor" .ColHeader(4) = flexColHeaderOn .ColWidth(0, 4) = 0 .ColWidth(1, 4) = 0 .ColHeaderCaption(4, 2) = "Sem Taken" .ColHeaderCaption(4, 3) = "Grade" End With End Sub This shows the Form_Load for try 7 which establishes the flex grid.

PrStuHier.vbp (Try8) This shows two of the three forms (the third form is similar to the second) and the information contained in the bas module. Note that there is a public connection of conStuHier in the bas module.

PrStuHier.vbp (Try8) This is the output on the first form. The grid lists the information by student. Then the major information is shown and finally the course information.

DIM the recordsets that will contain the needed information. Dim rsStudent00 As ADODB.Recordset Dim StuCoursesInfo As ADODB.Recordset Dim MajorInfo As ADODB.Recordset PrStuHier.vbp (Try8) DIM the recordsets that will contain the needed information. Private Sub Form_Load() Dim DBPath As String DBPath = App.Path If Right(DBPath, 1) <> "\" Then DBPath = DBPath & "\" End If DBPath = DBPath & "studentrel00.mdb" Set comStuHier = New ADODB.Connection With comStuHier .ConnectionString = "Provider = MSDataShape;" & _ "Data Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Persist Security Info=False;" & _ "Data Source=" & DBPath .Open End With Set rsStudent00 = New ADODB.Recordset Dim SQLCmd As String SQLCmd = "SHAPE {SELECT studentidno, name, city, majorcode FROM student00} AS Student00 " & _ "APPEND ({SELECT majorcode, majorname, advisor FROM major00} AS Major00 " & _ "RELATE 'majorcode' TO 'majorcode') AS Major00, " & _ "({SELECT * FROM stucourse00} AS StuCourses00 " & _ "RELATE 'studentidno' TO 'studentidno') AS StuCourses00" With rsStudent00 .CursorLocation = adUseClient .CursorType = adOpenDynamic .LockType = adLockOptimistic .Open SQLCmd, comStuHier, , , adCmdText Set up the connection string with MSDataShape because the shape language is being used. The shape command can be developed in the Data Environment and then brought over here. In this example the student information is first and is related to both the major information and the student information. Prior to open on the rsStudent00, the cursor location, cursor type and lock type are specified. The resordset is opened using the shape command in SQLCmd.

Note that there was an End Sub at the bottom that does not fit. Set MajorInfo = rsStudent00.Fields("Major00").Value Set StuCoursesInfo = rsStudent00.Fields("StuCourses00").Value Set txtstudentidno.DataSource = rsStudent00 Set txtname.DataSource = rsStudent00 Set txtmajorcode.DataSource = rsStudent00 Set txtmajorname.DataSource = MajorInfo With dgdCourses Set .DataSource = StuCoursesInfo .Columns(0).Caption = "Stu ID #" .Columns(1).Caption = "Crs Cd" .Columns(2).Caption = "Semester" .Columns(3).Caption = "Grade" .Refresh End With With flxStuHier Set .DataSource = rsStudent00 .RowHeight(0) = 0 .ColHeader(0) = flexColHeaderOn .ColHeaderCaption(0, 1) = "Stu ID#" .ColWidth(1, 0) = 650 .ColHeaderCaption(0, 2) = "Name" .ColWidth(2, 0) = 1800 .ColHeaderCaption(0, 3) = "City" .ColHeader(1) = flexColHeaderOn .ColWidth(4, 0) = 0 .ColHeaderCaption(1, 0) = "Maj Cd" .ColWidth(0, 1) = 600 .ColHeaderCaption(1, 1) = "Major Name" .ColWidth(1, 1) = 1800 .ColHeaderCaption(1, 2) = "Major Advisor" .ColWidth(2, 1) = 1800 .ColHeader(2) = flexColHeaderOn .ColWidth(0, 2) = 0 .ColHeaderCaption(2, 1) = "Course Cd" .ColHeaderCaption(2, 2) = "Sem. Taken" .ColHeaderCaption(2, 3) = "Grade" PrStuHier.vbp (Try8) MajorInfo and StuCoursesInfo are set with information from the rsStudent00 with the fields on the appropriate table. This allow the developer to get the information needed for the text boxes and the data grid. Now MajorInfo and StuCourses Infor are set, the columns on the grid are captioned and the data source is established. Finally the columns on the hierarchy flex grid are set and the data source is established. Note the use of the bands. Note that there was an End Sub at the bottom that does not fit.

PrStuHier.vbp (Try8) On this form, the information is by major. The major is shown followed by the students in that major followed by the courses they have taken.

Option Explicit Dim rsStudent00 As ADODB.Recordset PrStuHier.vbp (Try8) Private Sub Form_Load() Set rsStudent00 = New ADODB.Recordset Dim SQLCmd As String SQLCmd = "SHAPE {SELECT * FROM major00 ORDER BY majorname} AS Major00 " & _ "APPEND ((SHAPE {SELECT studentidno, name, city, majorcode FROM student00} AS Student00 " & _ "APPEND ({SELECT * FROM stucourse00 ORDER BY studentidno, coursecd} AS StuCourses00 " & _ "RELATE 'studentidno' TO 'studentidno') AS StuCourses00) AS Student00 " & _ "RELATE 'majorcode' TO 'majorcode') AS Student00 " With rsStudent00 .CursorLocation = adUseClient .CursorType = adOpenDynamic .LockType = adLockOptimistic .Open SQLCmd, comStuHier, , , adCmdText End With With flxStuHier Set .DataSource = rsStudent00 .RowHeight(0) = 0 .ColHeader(0) = flexColHeaderOn .ColHeaderCaption(0, 1) = "Maj Cd" .ColWidth(1, 0) = 650 .ColHeaderCaption(0, 2) = "Major Name" .ColWidth(2, 0) = 2200 .ColHeaderCaption(0, 3) = "Major Advisor" .ColWidth(3, 0) = 1800 .ColHeader(1) = flexColHeaderOn .ColHeaderCaption(1, 0) = "Stu ID" .ColWidth(0, 1) = 900 .ColHeaderCaption(1, 1) = "Student Name" .ColWidth(1, 1) = 1800 .ColHeaderCaption(1, 2) = "City" .ColWidth(2, 1) = 1800 .ColWidth(3, 1) = 0 .ColHeader(2) = flexColHeaderOn .ColWidth(0, 2) = 0 .ColHeaderCaption(2, 1) = "Course Cd" .ColHeaderCaption(2, 2) = "Sem. Taken" .ColHeaderCaption(2, 3) = "Grade" End Sub This shows the shape state for the by major listing on the previous page.

PrStuHier.vbp (Try8) This shows the information by course which is connected to student and major and then to when the student took the course.

Option Explicit Dim rsStudent00 As ADODB.Recordset PrStuHier.vbp (Try8) Private Sub Form_Load() Set rsStudent00 = New ADODB.Recordset Dim SQLCmd As String SQLCmd = "SHAPE {SELECT course00.* FROM course00 ORDER BY coursecd} AS Courses " & _ "APPEND (( SHAPE {SELECT DISTINCT coursecd, studentidno FROM stucourse00 ORDER BY coursecd, studentidno} AS CrsStuLnk " & _ "APPEND (( SHAPE {SELECT studentidno, name, majorcode FROM student00 ORDER BY studentidno} AS Students " & _ "APPEND ({SELECT major00.* FROM major00} AS Majors " & _ "RELATE 'majorcode' TO 'majorcode') AS Majors) AS Students " & _ "RELATE 'studentidno' TO 'studentidno') AS Students, " & _ "({SELECT stucourse00.* FROM stucourse00 ORDER BY coursecd, studentidno, grade} AS StuCrsData " & _ "RELATE 'coursecd' TO 'coursecd','studentidno' TO 'studentidno') AS StuCrsData) AS CrsStuLnk " & _ "RELATE 'coursecd' TO 'coursecd') AS CrsStuLnk" With rsStudent00 .CursorLocation = adUseClient .CursorType = adOpenDynamic .LockType = adLockOptimistic .Open SQLCmd, comStuHier, , , adCmdText End With With flxStuHierY Set .DataSource = rsStudent00 .RowHeight(0) = 0 .ColHeader(0) = flexColHeaderOn .ColWidth(1, 0) = 650 .ColHeaderCaption(0, 1) = "Crs Cd" .ColWidth(2, 0) = 2500 .ColHeaderCaption(0, 2) = "Course" .ColWidth(3, 0) = 650 .ColHeaderCaption(0, 3) = "Credits" .ColWidth(0, 1) = 0 .ColWidth(1, 1) = 0 .ColHeaderCaption(2, 0) = "Stu ID#" .ColWidth(1, 2) = 1800 .ColHeaderCaption(2, 1) = "Student Name" .ColWidth(2, 2) = 650 .ColHeaderCaption(2, 2) = "Maj Cd" .ColWidth(0, 3) = 0 .ColWidth(1, 3) = 1800 .ColHeaderCaption(3, 1) = "Major" .ColWidth(2, 3) = 1800 .ColHeaderCaption(3, 2) = "Advisor" .ColHeader(4) = flexColHeaderOn .ColWidth(0, 4) = 0 .ColWidth(1, 4) = 0 .ColHeaderCaption(4, 2) = "Sem Taken" .ColHeaderCaption(4, 3) = "Grade" End Sub This shows the connection by course. It follows the logic developed in the data environment in try7.

PrStuHier.vbp (Try9) Version 9 produces the same results as version 8. There are minor differences in the code. For example, bout the connection and the recordset are defined in the bas module.

PrStuHier.vbp (Try9) Dim StuCoursesInfo As ADODB.Recordset Dim MajorInfo As ADODB.Recordset Dim rsStu00BkMrk As Variant Dim SQLCmd As String Private Sub Form_Load() Dim DBPath As String DBPath = App.Path If Right(DBPath, 1) <> "\" Then DBPath = DBPath & "\" End If DBPath = DBPath & "studentrel00.mdb" Set comStuHier = New ADODB.Connection With comStuHier .ConnectionString = "Provider = MSDataShape;" & _ "Data Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Persist Security Info=False;" & _ "Data Source=" & DBPath .Open End With Set rsStudent00 = New ADODB.Recordset SQLCmd = "SHAPE {SELECT studentidno, name, city, majorcode FROM student00} AS Student00 " & _ "APPEND ({SELECT majorcode, majorname, advisor FROM major00} AS Major00 " & _ "RELATE 'majorcode' TO 'majorcode') AS Major00, " & _ "({SELECT * FROM stucourse00} AS StuCourses00 " & _ "RELATE 'studentidno' TO 'studentidno') AS StuCourses00" End Sub This shows the code for the main form where there are the text boxes, the regular grid and the hierarchy flex grid. See examples in try 8. The two recordsets that will contain information for the text boxes and the data grid have a dim statement here. The connection string is established using the public connection from the bas module and the rsstudent00 is set (note there was also a public declaration in the bas module). The shape language is used to put together the hierarchy by student.

PrStuHier.vbp (Try9) Private Sub Form_Activate() 'This routine is executed each time the form is activated. The Form_Load routine 'is executed only when the form is loaded into memory. With rsStudent00 If .State = adStateOpen Then .Close End If .CursorLocation = adUseClient .CursorType = adOpenDynamic .LockType = adLockOptimistic .Open SQLCmd, comStuHier, , , adCmdText If Not IsEmpty(rsStu00BkMrk) Then .Bookmark = rsStu00BkMrk End With Set MajorInfo = rsStudent00.Fields("Major00").Value Set StuCoursesInfo = rsStudent00.Fields("StuCourses00").Value Set txtstudentidno.DataSource = rsStudent00 Set txtname.DataSource = rsStudent00 Set txtmajorcode.DataSource = rsStudent00 Set txtmajorname.DataSource = MajorInfo With dgdCourses Set .DataSource = StuCoursesInfo .Columns(0).Caption = "Stu ID #" .Columns(1).Caption = "Crs Cd" .Columns(2).Caption = "Semester" .Columns(3).Caption = "Grade" .Refresh Whenever this form is activated, the code shown is executed. The check on state makes sure that the student is not already open prior to executing the open statement. If it is open, it is closed.

PrStuHier.vbp (Try9) With flxStuHier Set .DataSource = rsStudent00 .RowHeight(0) = 0 .ColHeader(0) = flexColHeaderOn .ColHeaderCaption(0, 1) = "Stu ID#" .ColWidth(1, 0) = 650 .ColHeaderCaption(0, 2) = "Name" .ColWidth(2, 0) = 1800 .ColHeaderCaption(0, 3) = "City" .ColHeader(1) = flexColHeaderOn .ColWidth(4, 0) = 0 .ColHeaderCaption(1, 0) = "Maj Cd" .ColWidth(0, 1) = 600 .ColHeaderCaption(1, 1) = "Major Name" .ColWidth(1, 1) = 1800 .ColHeaderCaption(1, 2) = "Major Advisor" .ColWidth(2, 1) = 1800 .ColHeader(2) = flexColHeaderOn .ColWidth(0, 2) = 0 .ColHeaderCaption(2, 1) = "Course Cd" .ColHeaderCaption(2, 2) = "Sem. Taken" .ColHeaderCaption(2, 3) = "Grade" End With End Sub PrStuHier.vbp (Try9) This shows the code to handle the hierarchy flex grid and the bookmarks. Private Sub cmdShwGrdX_Click() Me.Hide rsStu00BkMrk = rsStudent00.Bookmark rsStudent00.Close frmStuHierX.Show End Sub Private Sub cmdShwGrdY_Click() frmStuHierY.Show

Private Sub Form_Activate() With rsStudent00 If .State = adStateOpen Then .Close End If .CursorLocation = adUseClient .CursorType = adOpenDynamic .LockType = adLockOptimistic .Open SQLCmd, comStuHier, , , adCmdText End With With flxStuHier Set .DataSource = rsStudent00 .RowHeight(0) = 0 .ColHeader(0) = flexColHeaderOn .ColHeaderCaption(0, 1) = "Maj Cd" .ColWidth(1, 0) = 650 .ColHeaderCaption(0, 2) = "Major Name" .ColWidth(2, 0) = 2200 .ColHeaderCaption(0, 3) = "Major Advisor" .ColWidth(3, 0) = 1800 .ColHeader(1) = flexColHeaderOn .ColHeaderCaption(1, 0) = "Stu ID" .ColWidth(0, 1) = 900 .ColHeaderCaption(1, 1) = "Student Name" .ColWidth(1, 1) = 1800 .ColHeaderCaption(1, 2) = "City" .ColWidth(2, 1) = 1800 .ColWidth(3, 1) = 0 .ColHeader(2) = flexColHeaderOn .ColWidth(0, 2) = 0 .ColHeaderCaption(2, 1) = "Course Cd" .ColHeaderCaption(2, 2) = "Sem. Taken" .ColHeaderCaption(2, 3) = "Grade" End Sub Private Sub Form_Load() SQLCmd = "SHAPE {SELECT * FROM major00 ORDER BY majorname} AS Major00 " & _ "APPEND ((SHAPE {SELECT studentidno, name, city, majorcode FROM student00} AS Student00 " & _ "APPEND ({SELECT * FROM stucourse00 ORDER BY studentidno, coursecd} AS StuCourses00 " & _ "RELATE 'studentidno' TO 'studentidno') AS StuCourses00) AS Student00 " & _ "RELATE 'majorcode' TO 'majorcode') AS Student00 “ PrStuHier.vbp (Try9) This shows the form load and form activate for the hierarchy flex grid that will show the data by major. Note that the shape command is used once when the form is loaded. Each time the form is activated the information is opened and used.

PrStuHier.vbp (Try9) Private Sub Form_Activate() With rsStudent00 If .State = adStateOpen Then .Close End If .CursorLocation = adUseClient .CursorType = adOpenDynamic .LockType = adLockOptimistic .Open SQLCmd, comStuHier, , , adCmdText End With With flxStuHierY Set .DataSource = rsStudent00 .RowHeight(0) = 0 .ColHeader(0) = flexColHeaderOn .ColWidth(1, 0) = 650 .ColHeaderCaption(0, 1) = "Crs Cd" .ColWidth(2, 0) = 2500 .ColHeaderCaption(0, 2) = "Course" .ColWidth(3, 0) = 650 .ColHeaderCaption(0, 3) = "Credits" .ColWidth(0, 1) = 0 .ColWidth(1, 1) = 0 .ColHeaderCaption(2, 0) = "Stu ID#" .ColWidth(1, 2) = 1800 .ColHeaderCaption(2, 1) = "Student Name" .ColWidth(2, 2) = 650 .ColHeaderCaption(2, 2) = "Maj Cd" .ColWidth(0, 3) = 0 .ColWidth(1, 3) = 1800 .ColHeaderCaption(3, 1) = "Major" .ColWidth(2, 3) = 1800 .ColHeaderCaption(3, 2) = "Advisor" .ColHeader(4) = flexColHeaderOn .ColWidth(0, 4) = 0 .ColWidth(1, 4) = 0 .ColHeaderCaption(4, 2) = "Sem Taken" .ColHeaderCaption(4, 3) = "Grade" End Sub This shows the form activate for the by course hierarchy flex grid.

PrStuHier.vbp (Try9) Private Sub Form_Load() SQLCmd = "SHAPE {SELECT course00.* FROM course00 ORDER BY coursecd} AS Courses " & _ "APPEND (( SHAPE {SELECT DISTINCT coursecd, studentidno FROM stucourse00 ORDER BY coursecd, studentidno} AS CrsStuLnk " & _ "APPEND (( SHAPE {SELECT studentidno, name, majorcode FROM student00 ORDER BY studentidno} AS Students " & _ "APPEND ({SELECT major00.* FROM major00} AS Majors " & _ "RELATE 'majorcode' TO 'majorcode') AS Majors) AS Students " & _ "RELATE 'studentidno' TO 'studentidno') AS Students, " & _ "({SELECT stucourse00.* FROM stucourse00 ORDER BY coursecd, studentidno, grade} AS StuCrsData " & _ "RELATE 'coursecd' TO 'coursecd','studentidno' TO 'studentidno') AS StuCrsData) AS CrsStuLnk " & _ "RELATE 'coursecd' TO 'coursecd') AS CrsStuLnk" End Sub This shows the form load for the by course that was first examined in try 7.