home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / vb_code1 / bnd_read / readonly.frm < prev    next >
Text File  |  1994-04-06  |  4KB  |  137 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    Caption         =   "Data Control with Bound ReadOnly Text boxes"
  4.    ClientHeight    =   3825
  5.    ClientLeft      =   1095
  6.    ClientTop       =   1485
  7.    ClientWidth     =   6120
  8.    Height          =   4230
  9.    Left            =   1035
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   3825
  12.    ScaleWidth      =   6120
  13.    Top             =   1140
  14.    Width           =   6240
  15.    Begin CommandButton Command2 
  16.       Caption         =   "Push to make Read/Write"
  17.       Height          =   495
  18.       Left            =   3240
  19.       TabIndex        =   1
  20.       Top             =   2280
  21.       Width           =   2415
  22.    End
  23.    Begin CommandButton Command1 
  24.       Caption         =   "Push to make ReadOnly"
  25.       Height          =   495
  26.       Left            =   600
  27.       TabIndex        =   0
  28.       Top             =   2280
  29.       Width           =   2295
  30.    End
  31.    Begin TextBox Text2 
  32.       DataField       =   "Author"
  33.       DataSource      =   "Data1"
  34.       Height          =   375
  35.       Left            =   2040
  36.       TabIndex        =   3
  37.       Top             =   1440
  38.       Width           =   2415
  39.    End
  40.    Begin TextBox Text1 
  41.       DataField       =   "Au_ID"
  42.       DataSource      =   "Data1"
  43.       Height          =   375
  44.       Left            =   2640
  45.       TabIndex        =   2
  46.       Top             =   600
  47.       Width           =   1815
  48.    End
  49.    Begin Data Data1 
  50.       Caption         =   "Data1"
  51.       Connect         =   ""
  52.       DatabaseName    =   "C:\vb\BIBLIO.MDB"
  53.       Exclusive       =   0   'False
  54.       Height          =   270
  55.       Left            =   2040
  56.       Options         =   0
  57.       ReadOnly        =   0   'False
  58.       RecordSource    =   "Authors"
  59.       Top             =   3240
  60.       Width           =   2415
  61.    End
  62.    Begin Label Label3 
  63.       Alignment       =   2  'Center
  64.       AutoSize        =   -1  'True
  65.       Caption         =   "Default is set to Read/Write"
  66.       FontBold        =   -1  'True
  67.       FontItalic      =   -1  'True
  68.       FontName        =   "MS Sans Serif"
  69.       FontSize        =   9.75
  70.       FontStrikethru  =   0   'False
  71.       FontUnderline   =   0   'False
  72.       Height          =   240
  73.       Left            =   1635
  74.       TabIndex        =   6
  75.       Top             =   0
  76.       Width           =   2985
  77.    End
  78.    Begin Label Label2 
  79.       Caption         =   "Author Name:"
  80.       Height          =   255
  81.       Left            =   600
  82.       TabIndex        =   5
  83.       Top             =   1440
  84.       Width           =   1335
  85.    End
  86.    Begin Label Label1 
  87.       Caption         =   "Author Identification:"
  88.       Height          =   255
  89.       Left            =   600
  90.       TabIndex        =   4
  91.       Top             =   600
  92.       Width           =   1815
  93.    End
  94. End
  95. Option Explicit
  96. Dim readonly_flag%
  97.  
  98. Sub check_if_readonly (keyascii As Integer)
  99.  
  100.  If keyascii > 0 And readonly_flag% = 1 Then     '** if they press any key and readonly_flag% = 1 then
  101.   keyascii = 0                                   '** turn keystroke off
  102.  End If
  103.  
  104. End Sub
  105.  
  106. Sub Command1_Click ()
  107.  data1.ReadOnly = True       '*** set the incoming data to readonly
  108.  readonly_flag% = 1          '*** set readonly_flag% to 1 to makde text boxes readonly
  109.  label3.Caption = "ReadOnly record"
  110.  
  111. End Sub
  112.  
  113. Sub Command2_Click ()
  114.  data1.ReadOnly = False      '*** set the incoming data to read/write
  115.  readonly_flag% = 0          '*** set readonly_flag% to 0 to make text boxes read/write
  116.  label3.Caption = "Read/Write record"
  117.  
  118. End Sub
  119.  
  120. Sub Form_Load ()
  121.  readonly_flag% = 0        '** set default to read/write
  122.  
  123. End Sub
  124.  
  125. Sub Text1_KeyPress (keyascii As Integer)
  126.  
  127.  Call check_if_readonly(keyascii)
  128.  
  129. End Sub
  130.  
  131. Sub Text2_KeyPress (keyascii As Integer)
  132.  
  133.  Call check_if_readonly(keyascii)
  134.  
  135. End Sub
  136.  
  137.