home *** CD-ROM | disk | FTP | other *** search
/ Master 95 #1 / MASTER95_1.iso / microsof / vbasic4 / vb4-6.cab / muopt.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-07-26  |  5.7 KB  |  190 lines

  1. VERSION 4.00
  2. Begin VB.Form frmMUOptions 
  3.    BorderStyle     =   3  'Fixed Double
  4.    Caption         =   "Multi User Settings"
  5.    ClientHeight    =   810
  6.    ClientLeft      =   270
  7.    ClientTop       =   2565
  8.    ClientWidth     =   9105
  9.    Height          =   1215
  10.    HelpContextID   =   2016089
  11.    Icon            =   "MUOPT.frx":0000
  12.    Left            =   210
  13.    LinkTopic       =   "Form1"
  14.    LockControls    =   -1  'True
  15.    MaxButton       =   0   'False
  16.    MDIChild        =   -1  'True
  17.    MinButton       =   0   'False
  18.    ScaleHeight     =   810
  19.    ScaleWidth      =   9105
  20.    Top             =   2220
  21.    Width           =   9225
  22.    Begin VB.CommandButton cmdFreeLocks 
  23.       Caption         =   "&Free Locks"
  24.       Height          =   375
  25.       Left            =   7920
  26.       TabIndex        =   5
  27.       Top             =   45
  28.       Width           =   1095
  29.    End
  30.    Begin VB.CommandButton cmdRowsPerPage 
  31.       Caption         =   "&Add RowsPerPage Prop"
  32.       Height          =   375
  33.       Left            =   6000
  34.       TabIndex        =   4
  35.       Top             =   40
  36.       Width           =   1935
  37.    End
  38.    Begin VB.TextBox txtDelay 
  39.       Height          =   285
  40.       Left            =   1200
  41.       TabIndex        =   1
  42.       Top             =   480
  43.       Width           =   495
  44.    End
  45.    Begin VB.OptionButton optLocking 
  46.       Caption         =   "Optimistic - Lock occurs on Update"
  47.       Height          =   255
  48.       Index           =   1
  49.       Left            =   1800
  50.       TabIndex        =   3
  51.       Top             =   480
  52.       Width           =   4095
  53.    End
  54.    Begin VB.CommandButton cmdClose 
  55.       Cancel          =   -1  'True
  56.       Caption         =   "&Close"
  57.       Height          =   375
  58.       Left            =   7920
  59.       TabIndex        =   7
  60.       Top             =   405
  61.       Width           =   1095
  62.    End
  63.    Begin VB.CommandButton cmdSet 
  64.       Caption         =   "&Set for All Recordsets"
  65.       Default         =   -1  'True
  66.       Height          =   375
  67.       Left            =   6000
  68.       TabIndex        =   6
  69.       Top             =   400
  70.       Width           =   1935
  71.    End
  72.    Begin VB.OptionButton optLocking 
  73.       Caption         =   "Pessimistic - Lock occurs on Edit"
  74.       Height          =   255
  75.       Index           =   0
  76.       Left            =   1800
  77.       TabIndex        =   2
  78.       Top             =   120
  79.       Value           =   -1  'True
  80.       Width           =   4095
  81.    End
  82.    Begin VB.TextBox txtRetryCnt 
  83.       Height          =   285
  84.       Left            =   1200
  85.       TabIndex        =   0
  86.       Top             =   120
  87.       Width           =   495
  88.    End
  89.    Begin VB.Label lblLabels 
  90.       Caption         =   "Delay:"
  91.       Height          =   255
  92.       Index           =   1
  93.       Left            =   120
  94.       TabIndex        =   9
  95.       Top             =   480
  96.       Width           =   735
  97.    End
  98.    Begin VB.Label lblLabels 
  99.       Caption         =   "Retry Count:"
  100.       Height          =   255
  101.       Index           =   0
  102.       Left            =   120
  103.       TabIndex        =   8
  104.       Top             =   120
  105.       Width           =   975
  106.    End
  107. Attribute VB_Name = "frmMUOptions"
  108. Attribute VB_Creatable = False
  109. Attribute VB_Exposed = False
  110. Option Explicit
  111. Private Sub cmdClose_Click()
  112.   Unload Me
  113. End Sub
  114. Private Sub cmdRowsPerPage_Click()
  115.   Dim tdf As TableDef
  116.   Dim fld As Field
  117.   Dim prp As Property
  118.   Dim nRPPVal As Integer
  119.   Dim i As Integer, ii As Integer
  120.   SetHourglass
  121.   'add the property to each table
  122.   On Error Resume Next  'ignore error if it's there already
  123.   For Each tdf In gdbCurrentDB.TableDefs
  124.     If (tdf.Attributes And dbAttachedODBC) <> 0 Then GoTo SkipIt
  125.     If (tdf.Attributes And dbSystemObject) <> 0 Then GoTo SkipIt
  126.     If (tdf.Attributes And dbAttachedTable) = dbAttachedTable Then
  127.       If Left(tdf.Connect, 1) <> ";" Then
  128.         'must not be a jet table so RowsPerPage doesn't apply
  129.         GoTo SkipIt
  130.       End If
  131.     End If
  132.       
  133.     Set prp = tdf.CreateProperty("RowsPerPage", dbInteger, 0)
  134.     tdf.Properties.Append prp
  135.     'set the values of the property
  136.     nRPPVal = 8    'start with overhead of 8 bytes
  137.     For Each fld In tdf.Fields
  138.       If fld.Type < dbLongBinary Then
  139.         'this includes binary and memo fields
  140.         nRPPVal = nRPPVal + fld.Size
  141.       Else
  142.         nRPPVal = nRPPVal + 4
  143.       End If
  144.     Next
  145.     'assign the value using a 2k page / field total
  146.     tdf.Properties("RowsPerPage").Value = 2048 \ nRPPVal
  147. SkipIt:
  148.   Next
  149.   On Error GoTo RPPErr
  150.   MsgBox "All Tables now have a user defined property" & _
  151.          " called RowsPerPage that contains the number" & _
  152.          " of rows that will fit into a 2k Jet page" & _
  153.          " used in page locking. It is accessible through" & _
  154.          " the Properties collection on Tables and" & _
  155.          " Recordsets."
  156.   Screen.MousePointer = vbDefault
  157.   Exit Sub
  158. RPPErr:
  159.   ShowError
  160.   Exit Sub
  161. End Sub
  162. Private Sub cmdSet_Click()
  163.   On Error GoTo SETErr
  164.   Dim rec As Recordset
  165.   Dim i As Integer
  166.   gnMURetryCnt = txtRetryCnt.Text
  167.   gnMUDelay = txtDelay.Text
  168.   gnMULocking = optLocking(0).Value
  169.   'set the Lockedits prop for each open dynaset and table
  170.   For Each rec In gdbCurrentDB.Recordsets
  171.     If rec.Type <> dbOpenSnapshot Then
  172.       rec.LockEdits = gnMULocking
  173.     End If
  174.   Next
  175.   Exit Sub
  176. SETErr:
  177.   ShowError
  178.   Exit Sub
  179. End Sub
  180. Private Sub cmdFreeLocks_Click()
  181.   DBEngine.Idle dbFreeLocks
  182. End Sub
  183. Private Sub Form_Load()
  184.   txtRetryCnt.Text = gnMURetryCnt
  185.   txtDelay.Text = gnMUDelay
  186.   optLocking(0).Value = gnMULocking
  187.   Me.Left = 0
  188.   Me.Top = frmMDI.Height - frmMUOptions.Height - 1820
  189. End Sub
  190.