Text1(Index).SelStart = 0
Text1(Index).SelLength = Len(Text1(Index))
End Sub
Private Sub Text1_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn And Index < 5 Then Text1(Index + 1).SetFocus
End Sub
Private Sub Text1_LostFocus(Index As Integer)
Text1(Index).BackColor = &H80000005
End Sub
Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
Select Case Button.Key
Case "add"
Adodc1.Recordset.AddNew '添加新记录
'清空文本框,解除锁定
For i = 1 To Text1.UBound
Text1(i) = ""
Text1(i).Locked = False
Next i
Text1(0).SetFocus '使经手人编号text1(0)获得焦点
Case "save"
Adodc1.Recordset.Update '更新数据表
Case "xg"
'解除锁定,修改数据
For i = 1 To Text1.UBound
Text1(i).Locked = False
Next i
Case "cancel"
'取消操作,锁定文本框
For i = 1 To Text1.UBound
Text1(i).Locked = True
Next i
Case "del"
Adodc1.Recordset.Delete '删除记录
Adodc1.Recordset.Update '更新数据表
Case "close"
Unload Me '关闭窗体
End Select
End Sub
Private Sub DataGrid1_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
Text2.Text = DataGrid1.Columns("货品编号").Text
Text3.Text = DataGrid1.Columns("设备名称").Text
Text4.Text = DataGrid1.Columns("数量").Text
Text5.Text = DataGrid1.Columns("排").Text
Text6.Text = DataGrid1.Columns("列").Text
Text7.Text = DataGrid1.Columns("层").Text
End Sub
Private Sub Command1_Click()
MsgBox "出库完成前,请勿进行任何操作!!!"
End Sub
Private Sub Command2_Click()
MsgBox "入库完成前,请勿进行任何操作!!!"
End Sub
Private Sub Command3_Click()
Adodc1.RecordSource = "select * from 库存表 where 商品名称 like '*'+'" + Text8.Text + "'+'*'"
Adodc1.CommandType = adCmdText
Adodc1.Refresh
Set DataGrid1.DataSource = Adodc1
End Sub
Private Sub Adodc1_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)
If ErrorNumber = -2147217873 Then '如果错误号-2147217873
Scode = 0 '服务器返回错误码为0
MsgBox Description '输出错误描述信息
End If
End Sub