home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic 6 Unleashed…sional Reference Edition) / Visual_Basic_6_Unleashed_Professional_Reference_Edition_Sams_1999.iso / Source / CHAP16 / dfDemo.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1998-06-11  |  11.6 KB  |  357 lines

  1. VERSION 5.00
  2. Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
  3. Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
  4. Begin VB.Form dfForm 
  5.    Caption         =   "Customers"
  6.    ClientHeight    =   3645
  7.    ClientLeft      =   1110
  8.    ClientTop       =   345
  9.    ClientWidth     =   5745
  10.    KeyPreview      =   -1  'True
  11.    LinkTopic       =   "Form1"
  12.    ScaleHeight     =   3645
  13.    ScaleWidth      =   5745
  14.    Begin VB.PictureBox picButtons 
  15.       Align           =   2  'Align Bottom
  16.       Appearance      =   0  'Flat
  17.       BorderStyle     =   0  'None
  18.       ForeColor       =   &H80000008&
  19.       Height          =   300
  20.       Left            =   0
  21.       ScaleHeight     =   300
  22.       ScaleWidth      =   5745
  23.       TabIndex        =   11
  24.       Top             =   3015
  25.       Width           =   5745
  26.       Begin VB.CommandButton cmdClose 
  27.          Caption         =   "&Close"
  28.          Height          =   300
  29.          Left            =   4675
  30.          TabIndex        =   16
  31.          Top             =   0
  32.          Width           =   1095
  33.       End
  34.       Begin VB.CommandButton cmdRefresh 
  35.          Caption         =   "&Refresh"
  36.          Height          =   300
  37.          Left            =   3521
  38.          TabIndex        =   15
  39.          Top             =   0
  40.          Width           =   1095
  41.       End
  42.       Begin VB.CommandButton cmdDelete 
  43.          Caption         =   "&Delete"
  44.          Height          =   300
  45.          Left            =   2367
  46.          TabIndex        =   14
  47.          Top             =   0
  48.          Width           =   1095
  49.       End
  50.       Begin VB.CommandButton cmdUpdate 
  51.          Caption         =   "&Update"
  52.          Height          =   300
  53.          Left            =   1213
  54.          TabIndex        =   13
  55.          Top             =   0
  56.          Width           =   1095
  57.       End
  58.       Begin VB.CommandButton cmdAdd 
  59.          Caption         =   "&Add"
  60.          Height          =   300
  61.          Left            =   59
  62.          TabIndex        =   12
  63.          Top             =   0
  64.          Width           =   1095
  65.       End
  66.    End
  67.    Begin VB.TextBox txtFields 
  68.       DataField       =   "Phone"
  69.       DataSource      =   "datPrimaryRS"
  70.       Height          =   285
  71.       Index           =   4
  72.       Left            =   2040
  73.       TabIndex        =   9
  74.       Top             =   1340
  75.       Width           =   3375
  76.    End
  77.    Begin VB.TextBox txtFields 
  78.       DataField       =   "City"
  79.       DataSource      =   "datPrimaryRS"
  80.       Height          =   285
  81.       Index           =   3
  82.       Left            =   2040
  83.       TabIndex        =   7
  84.       Top             =   1020
  85.       Width           =   3375
  86.    End
  87.    Begin VB.TextBox txtFields 
  88.       DataField       =   "ContactName"
  89.       DataSource      =   "datPrimaryRS"
  90.       Height          =   285
  91.       Index           =   2
  92.       Left            =   2040
  93.       TabIndex        =   5
  94.       Top             =   700
  95.       Width           =   3375
  96.    End
  97.    Begin VB.TextBox txtFields 
  98.       DataField       =   "CompanyName"
  99.       DataSource      =   "datPrimaryRS"
  100.       Height          =   285
  101.       Index           =   1
  102.       Left            =   2040
  103.       TabIndex        =   3
  104.       Top             =   380
  105.       Width           =   3375
  106.    End
  107.    Begin VB.TextBox txtFields 
  108.       DataField       =   "CustomerID"
  109.       DataSource      =   "datPrimaryRS"
  110.       Height          =   285
  111.       Index           =   0
  112.       Left            =   2040
  113.       TabIndex        =   1
  114.       Top             =   60
  115.       Width           =   3375
  116.    End
  117.    Begin MSAdodcLib.Adodc datPrimaryRS 
  118.       Align           =   2  'Align Bottom
  119.       Height          =   330
  120.       Left            =   0
  121.       Top             =   3315
  122.       Width           =   5745
  123.       _ExtentX        =   10134
  124.       _ExtentY        =   582
  125.       ConnectMode     =   0
  126.       CursorLocation  =   3
  127.       IsolationLevel  =   -1
  128.       ConnectionTimeout=   15
  129.       CommandTimeout  =   30
  130.       CursorType      =   3
  131.       LockType        =   3
  132.       CommandType     =   8
  133.       CursorOptions   =   0
  134.       CacheSize       =   50
  135.       MaxRecords      =   0
  136.       BOFAction       =   0
  137.       EOFAction       =   0
  138.       ConnectStringType=   1
  139.       Appearance      =   1
  140.       BackColor       =   -2147483643
  141.       ForeColor       =   -2147483640
  142.       Orientation     =   0
  143.       Enabled         =   -1
  144.       Connect         =   "PROVIDER=MSDataShape;Data PROVIDER=MSDASQL;dsn=NWIND;uid=;pwd=;"
  145.       OLEDBString     =   "PROVIDER=MSDataShape;Data PROVIDER=MSDASQL;dsn=NWIND;uid=;pwd=;"
  146.       OLEDBFile       =   ""
  147.       DataSourceName  =   ""
  148.       OtherAttributes =   ""
  149.       UserName        =   ""
  150.       Password        =   ""
  151.       RecordSource    =   $"dfDemo.frx":0000
  152.       Caption         =   " "
  153.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  154.          Name            =   "MS Sans Serif"
  155.          Size            =   8.25
  156.          Charset         =   0
  157.          Weight          =   400
  158.          Underline       =   0   'False
  159.          Italic          =   0   'False
  160.          Strikethrough   =   0   'False
  161.       EndProperty
  162.       _Version        =   393216
  163.    End
  164.    Begin MSDataGridLib.DataGrid grdDataGrid 
  165.       Height          =   1300
  166.       Left            =   0
  167.       TabIndex        =   10
  168.       Top             =   1660
  169.       Width           =   5765
  170.       _ExtentX        =   10160
  171.       _ExtentY        =   2302
  172.       _Version        =   393216
  173.       AllowUpdate     =   0   'False
  174.       HeadLines       =   1
  175.       RowHeight       =   15
  176.       BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  177.          Name            =   "MS Sans Serif"
  178.          Size            =   8.25
  179.          Charset         =   0
  180.          Weight          =   400
  181.          Underline       =   0   'False
  182.          Italic          =   0   'False
  183.          Strikethrough   =   0   'False
  184.       EndProperty
  185.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  186.          Name            =   "MS Sans Serif"
  187.          Size            =   8.25
  188.          Charset         =   0
  189.          Weight          =   400
  190.          Underline       =   0   'False
  191.          Italic          =   0   'False
  192.          Strikethrough   =   0   'False
  193.       EndProperty
  194.       ColumnCount     =   2
  195.       BeginProperty Column00 
  196.          DataField       =   ""
  197.          Caption         =   ""
  198.          BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
  199.             Type            =   0
  200.             Format          =   ""
  201.             HaveTrueFalseNull=   0
  202.             FirstDayOfWeek  =   0
  203.             FirstWeekOfYear =   0
  204.             LCID            =   1033
  205.             SubFormatType   =   0
  206.          EndProperty
  207.       EndProperty
  208.       BeginProperty Column01 
  209.          DataField       =   ""
  210.          Caption         =   ""
  211.          BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
  212.             Type            =   0
  213.             Format          =   ""
  214.             HaveTrueFalseNull=   0
  215.             FirstDayOfWeek  =   0
  216.             FirstWeekOfYear =   0
  217.             LCID            =   1033
  218.             SubFormatType   =   0
  219.          EndProperty
  220.       EndProperty
  221.       SplitCount      =   1
  222.       BeginProperty Split0 
  223.          BeginProperty Column00 
  224.          EndProperty
  225.          BeginProperty Column01 
  226.          EndProperty
  227.       EndProperty
  228.    End
  229.    Begin VB.Label lblLabels 
  230.       Caption         =   "Phone:"
  231.       Height          =   255
  232.       Index           =   4
  233.       Left            =   120
  234.       TabIndex        =   8
  235.       Top             =   1340
  236.       Width           =   1815
  237.    End
  238.    Begin VB.Label lblLabels 
  239.       Caption         =   "City:"
  240.       Height          =   255
  241.       Index           =   3
  242.       Left            =   120
  243.       TabIndex        =   6
  244.       Top             =   1020
  245.       Width           =   1815
  246.    End
  247.    Begin VB.Label lblLabels 
  248.       Caption         =   "ContactName:"
  249.       Height          =   255
  250.       Index           =   2
  251.       Left            =   120
  252.       TabIndex        =   4
  253.       Top             =   700
  254.       Width           =   1815
  255.    End
  256.    Begin VB.Label lblLabels 
  257.       Caption         =   "CompanyName:"
  258.       Height          =   255
  259.       Index           =   1
  260.       Left            =   120
  261.       TabIndex        =   2
  262.       Top             =   380
  263.       Width           =   1815
  264.    End
  265.    Begin VB.Label lblLabels 
  266.       Caption         =   "CustomerID:"
  267.       Height          =   255
  268.       Index           =   0
  269.       Left            =   120
  270.       TabIndex        =   0
  271.       Top             =   60
  272.       Width           =   1815
  273.    End
  274. Attribute VB_Name = "dfForm"
  275. Attribute VB_GlobalNameSpace = False
  276. Attribute VB_Creatable = False
  277. Attribute VB_PredeclaredId = True
  278. Attribute VB_Exposed = False
  279. Private Sub Form_Load()
  280.   Set grdDataGrid.DataSource = datPrimaryRS.Recordset("ChildCMD").UnderlyingValue
  281. End Sub
  282. Private Sub Form_Resize()
  283.   On Error Resume Next
  284.   'This will resize the grid when the form is resized
  285.   grdDataGrid.Width = Me.ScaleWidth
  286.   grdDataGrid.Height = Me.ScaleHeight - grdDataGrid.Top - datPrimaryRS.Height - 30 - picButtons.Height
  287. End Sub
  288. Private Sub Form_Unload(Cancel As Integer)
  289.   Screen.MousePointer = vbDefault
  290. End Sub
  291. Private Sub datPrimaryRS_Error(ByVal ErrorNumber As Long, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, fCancelDisplay As Boolean)
  292.   'This is where you would put error handling code
  293.   'If you want to ignore errors, comment out the next line
  294.   'If you want to trap them, add code here to handle them
  295.   MsgBox "Data error event hit err:" & Description
  296. End Sub
  297. Private Sub datPrimaryRS_MoveComplete(ByVal adReason As ADODB.EventReasonEnum, ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
  298.   'This will display the current record position for this recordset
  299.   datPrimaryRS.Caption = "Record: " & CStr(datPrimaryRS.Recordset.AbsolutePosition)
  300. End Sub
  301. Private Sub datPrimaryRS_WillChangeRecord(ByVal adReason As ADODB.EventReasonEnum, ByVal cRecords As Long, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
  302.   'This is where you put validation code
  303.   'This event gets called when the following actions occur
  304.   Dim bCancel As Boolean
  305.   Select Case adReason
  306.   Case adRsnAddNew
  307.   Case adRsnClose
  308.   Case adRsnDelete
  309.   Case adRsnFirstChange
  310.   Case adRsnMove
  311.   Case adRsnRequery
  312.   Case adRsnResynch
  313.   Case adRsnUndoAddNew
  314.   Case adRsnUndoDelete
  315.   Case adRsnUndoUpdate
  316.   Case adRsnUpdate
  317.   End Select
  318.   If bCancel Then adStatus = adStatusCancel
  319. End Sub
  320. Private Sub cmdAdd_Click()
  321.   On Error GoTo AddErr
  322.   datPrimaryRS.Recordset.AddNew
  323.   Exit Sub
  324. AddErr:
  325.   MsgBox Err.Description
  326. End Sub
  327. Private Sub cmdDelete_Click()
  328.   On Error GoTo DeleteErr
  329.   With datPrimaryRS.Recordset
  330.     .Delete
  331.     .MoveNext
  332.     If .EOF Then .MoveLast
  333.   End With
  334.   Exit Sub
  335. DeleteErr:
  336.   MsgBox Err.Description
  337. End Sub
  338. Private Sub cmdRefresh_Click()
  339.   'This is only needed for multi user apps
  340.   On Error GoTo RefreshErr
  341.   datPrimaryRS.Refresh
  342.   Set grdDataGrid.DataSource = datPrimaryRS.Recordset("ChildCMD").UnderlyingValue
  343.   Exit Sub
  344. RefreshErr:
  345.   MsgBox Err.Description
  346. End Sub
  347. Private Sub cmdUpdate_Click()
  348.   On Error GoTo UpdateErr
  349.   datPrimaryRS.Recordset.UpdateBatch adAffectAll
  350.   Exit Sub
  351. UpdateErr:
  352.   MsgBox Err.Description
  353. End Sub
  354. Private Sub cmdClose_Click()
  355.   Unload Me
  356. End Sub
  357.