📄 selector.frm
字号:
VERSION 5.00
Begin VB.Form frmSelector
BackColor = &H00C0C0C0&
BorderStyle = 1 'Fixed Single
ClientHeight = 2610
ClientLeft = 2580
ClientTop = 2655
ClientWidth = 4110
ControlBox = 0 'False
LinkTopic = "Form2"
MaxButton = 0 'False
MinButton = 0 'False
PaletteMode = 1 'UseZOrder
ScaleHeight = 2610
ScaleWidth = 4110
Begin VB.CommandButton cmdCancel
Cancel = -1 'True
Caption = "&Cancel"
Height = 555
Left = 2820
TabIndex = 3
Top = 1920
Width = 1155
End
Begin VB.CommandButton cmdOK
Caption = "&OK"
Default = -1 'True
Height = 555
Left = 1530
TabIndex = 2
Top = 1920
Width = 1155
End
Begin VB.ListBox lstBox
Height = 1425
Left = 120
TabIndex = 0
Top = 330
Width = 3855
End
Begin VB.Label lblList
BackColor = &H00C0C0C0&
Height = 165
Left = 120
TabIndex = 1
Top = 90
Width = 2715
End
End
Attribute VB_Name = "frmSelector"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Function ListTables(blnAttach As Boolean, strFileSpec As String) _
As Integer
Dim dbfTemp As Database, tdfTemp As TableDef
Dim intTablesAdded As Integer
lstBox.Clear
On Error GoTo ListTablesError
Screen.MousePointer = vbHourglass
Set dbfTemp = DBEngine.Workspaces(0).OpenDatabase(strFileSpec)
intTablesAdded = 0
For Each tdfTemp In dbfTemp.TableDefs
If blnAttach Then
If Left$(tdfTemp.Name, 4) <> "MSys" And _
tdfTemp.Attributes <> dbAttachedTable And _
tdfTemp.Attributes <> dbAttachSavePWD And _
tdfTemp.Attributes <> dbAttachExclusive Then
lstBox.AddItem tdfTemp.Name
intTablesAdded = intTablesAdded + 1
End If
ElseIf tdfTemp.Attributes = dbAttachedTable Or _
tdfTemp.Attributes = dbAttachSavePWD Or _
tdfTemp.Attributes = dbAttachExclusive Then
lstBox.AddItem tdfTemp.Name
intTablesAdded = intTablesAdded + 1
End If
Next
Screen.MousePointer = vbDefault
ListTables = intTablesAdded
Exit Function
ListTablesError:
Screen.MousePointer = vbDefault
MsgBox Err.Description, vbExclamation
ListTables = 0
Exit Function
End Function
Private Sub cmdOK_Click()
If lstBox.ListIndex > -1 Then
frmSelector.Hide
Else
MsgBox "You have not yet made a selection.", vbExclamation
End If
End Sub
Private Sub Form_Load()
End Sub
Private Sub lstBox_DblClick()
cmdOK_Click
End Sub
Private Sub cmdCancel_Click()
lstBox.ListIndex = -1
frmSelector.Hide
End Sub
Public Function Display(ByVal blnAttach As Boolean, ByVal strFileSpec As String) As String
With Me
.Caption = "Table to " & IIf(blnAttach, "Attach", "Detach")
.lblList = "Select table to " & IIf(blnAttach, "attach:", "detach:")
End With
If ListTables(blnAttach, strFileSpec) Then
Me.Show vbModal
Else
MsgBox "There are no attached tables in " & GetFileName(strFileSpec) & "."
End If
If lstBox.ListIndex > -1 Then Display = lstBox.Text
End Function
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -