frmproducttypel.frm

来自「通用书店管理系统」· FRM 代码 · 共 159 行

FRM
159
字号
VERSION 5.00
Begin VB.Form frmProductTypeL 
   Appearance      =   0  'Flat
   BackColor       =   &H00C0E0FF&
   Caption         =   "基础代码管理"
   ClientHeight    =   1665
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   3570
   LinkTopic       =   "Form1"
   ScaleHeight     =   1665
   ScaleWidth      =   3570
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton cmdExit 
      Appearance      =   0  'Flat
      Height          =   435
      Left            =   1980
      Picture         =   "frmProductTypeL.frx":0000
      Style           =   1  'Graphical
      TabIndex        =   5
      Top             =   1020
      Width           =   975
   End
   Begin VB.CommandButton cmdSave 
      Appearance      =   0  'Flat
      Default         =   -1  'True
      Height          =   435
      Left            =   660
      Picture         =   "frmProductTypeL.frx":14E4
      Style           =   1  'Graphical
      TabIndex        =   2
      Top             =   1020
      Width           =   975
   End
   Begin VB.TextBox txtFields 
      Appearance      =   0  'Flat
      Height          =   330
      Index           =   1
      Left            =   1320
      TabIndex        =   1
      Top             =   480
      Width           =   1935
   End
   Begin VB.TextBox txtFields 
      Appearance      =   0  'Flat
      BackColor       =   &H80000014&
      Height          =   330
      Index           =   0
      Left            =   1320
      TabIndex        =   0
      Top             =   60
      Width           =   1935
   End
   Begin VB.Label Label1 
      Appearance      =   0  'Flat
      BackColor       =   &H00C0E0FF&
      Caption         =   "制品类型"
      ForeColor       =   &H80000008&
      Height          =   330
      Index           =   0
      Left            =   120
      TabIndex        =   4
      Top             =   165
      Width           =   1095
   End
   Begin VB.Label Label1 
      Appearance      =   0  'Flat
      BackColor       =   &H00C0E0FF&
      Caption         =   "类型名称"
      ForeColor       =   &H80000008&
      Height          =   225
      Index           =   1
      Left            =   120
      TabIndex        =   3
      Top             =   585
      Width           =   1095
   End
End
Attribute VB_Name = "frmProductTypeL"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Public strBeginString As String     ' 用户预输入字符串
Public strTableName As String
Public strColName As String
Public strLastID As String
Public strLastName As String
Public blnOK As Boolean

Private Sub cmdExit_Click()
    ReSet
    Me.Hide
End Sub

Private Sub CmdSave_Click()
    Dim rs As ADODB.Recordset
    Dim strSQL As String
  
    On Error GoTo err
    If txtFields(0).Text = "" Then
        txtFields(0).SetFocus
        Exit Sub
    End If
    If txtFields(1).Text = "" Then
        txtFields(1).SetFocus
        Exit Sub
    End If
    
    
    '从记录表中查找是否存在该记录
    strSQL = "select * from " & strTableName & " where " & strColName & "='" & txtFields(0).Text & "'"
    Set rs = New ADODB.Recordset
    rs.Open strSQL, cN, adOpenStatic, adLockOptimistic
    rs.AddNew
    rs.Fields(0) = Trim(txtFields(0).Text)
    rs.Fields(1) = Trim(txtFields(1).Text)
    rs.Update
    
    blnOK = True
    Me.strLastID = Trim(txtFields(0).Text)
    Me.strLastName = Trim(txtFields(1).Text)
    cmdExit_Click
    Exit Sub
err:
    blnOK = False
    MsgBox "保存记录时出错:" & err.Description, vbInformation
    Exit Sub
End Sub

Private Sub Form_Load()
    strLastID = ""
    strLastName = ""
    If Len(Me.strBeginString) > 0 Then
        If DBLen(Me.strBeginString) = Len(Me.strBeginString) Then
            txtFields(0).Text = Me.strBeginString
'            txtFields(1).SetFocus
        Else
            txtFields(1).Text = Me.strBeginString
'            txtFields(0).SetFocus
        End If
    End If
End Sub

Private Sub ReSet()
    txtFields(0).Text = ""
    txtFields(1).Text = ""
End Sub



Private Sub txtFields_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
    If KeyCode = vbKeyReturn Then
        SendKeys "{TAB}"
        Exit Sub
    End If
End Sub

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?