Page 1
Page 2
Page 3
Page 4
Page 5
Page 6
Once the user selects to view a table, a combo
box appears, with all available tables. The users selects a table,
and two new buttons appear on the screen. Where the information
can be viewed in a grid like format, or on a record by record
basis. Where each record is displayed in columnar display.

Private Sub List1_Click()
'Display message when a table has been chosen
Me.lblDispMsg.Caption = "Select View Type"
End Sub
CODE 8 (Form)
Next Lets see what happens when we select
to view the information in a Grid View.
Private Sub cmdViewGrid_Click()
'Display Grid View, show all recrods at once
Me.List1.Visible = False
Me.lblDispMsg.Caption = "Loading Database Please Wait"
Screen.MousePointer = 11
'Call the LoadRecSet function to get a listing of
'all the fields in the table
LoadRecSet
'By reading the table name selected in List1, execute
'function DispGrid and load the Grid with all the records
'from the selected table
DispGrid List1.Text
'Make sure the text box for displaying the detailed information
'the correct height
txtBox.Height = 492
Me.txtBox.Visible = True
BtnShow ("000110000")
Screen.MousePointer = 0
If cmdViewGrid.Width > 1600 Then cmdViewGrid.Enabled = False
End Sub
CODE 9 (Form)
LoadRecSet() Function is in the Form, and
it loads the selected table into the rsWorkingTbl recordset
Private Sub LoadRecSet()
'Assing contects of the txtBox to Variable sSQL
'if the user has chosen to run a SELECT statment
'the contents of the txtBox is transfered to sSQL
'becuase the actuall recordsets are created in the Main
'module, and using a public variable simplifes the matter
If Mid(txtBox, 1, 6) = "SELECT" Then
sSQL = txtBox
Else
sSQL = " "
End If
'Get the Selected Table
sList = List1.Text
'Open Table
OpenTable
'Read in the Field Names
GetRecsFlds
BtnShow ("000110000")
End Sub
CODE 10(Form)
From the LoadRecSet() Function two other routines
are loaded.
1) OpenTable() Function which initilizes the
record set rsWorkingTbl, which the program will then use to display
the requested data
Public Sub OpenTable()
'Open Table to View
'Store information in rsWorkingTbl RecordSet
Dim sFind As String
Dim sSlctOpen As String
Set rsWorkingTbl = CreateObject("ADOCE.Recordset.3.0")
'Test to see if the txtBox starts with SELECT if does 'not then
read the table code from MsysTables, which 'you can then use to
identify the field names from 'MSysFields Else if SELECT is used
then go to Else 'statment and run the SQL statment as typed
If Mid(sSQL, 1, 6) <> "SELECT" Then
sSelect = sList
sTable = sSelect
Set rsTables = CreateObject("ADOCE.Recordset.3.0")
sSlctOpen = "SELECT TableName, TableID FROM MSysTables WHERE
TableName = '" & sTable & "'"
rsTables.Open sSlctOpen, conndb, adOpenKeyset, adLockOptimistic
rsTables.MoveFirst
sTableNo = rsTables.Fields("TableID")
rsTables.Close
Set rsTables = Nothing
Else
sSelect = sSQL
End If
rsWorkingTbl.Open sSelect, conndb, adOpenKeyset, adLockOptimistic
rsWorkingTbl.MoveLast
iRecCnt = rsWorkingTbl.RecordCount
rsWorkingTbl.MoveFirst
End Sub
CODE 11 (Main Module)
2) GetRecsFlds() function opens the MsysFields
table and reads the field definitions for the selected table,
loaded into rsWorkingTbl recordset. Later on this will display
the names of the fields when we view the information on a record
by record basis.
Public Sub GetRecsFlds()
'Get the Fields Names from the MSysFields Table
'Store the Names and Type in the rsRecords Recordset
Dim sSQLRecs As String
Set rsRecords = CreateObject("ADOCE.Recordset.3.0")
sSQLRecs = "SELECT " & _
"MsysFields.TableID, " & _
"MSysFields.FieldName, " & _
"MSysFields.Len, " & _
"MSysFields.ODBCType " & _
"FROM MsysFields WHERE " & _
"TableID = '" & sTableNo & "'"
rsRecords.Open sSQLRecs, conndb
End Sub
CODE 12 (Main Module)
Previous Page
Next Page