excel窗体导出到VB提示方法和数据成员未找到
PrivateSubCommandButton1_Click()OnErrorGoTo100IfTextBox1.Text=""ThenMsgBox"请输入序号",1+1...
Private Sub CommandButton1_Click()
On Error GoTo 100
If TextBox1.Text = "" Then
MsgBox "请输入序号", 1 + 16, "出错提示"
TextBox1.SetFocus
Else
Dim RS1 As Recordset
Dim DB1 As Database
Set DB1 = OpenDatabase("\\192.168.1.254\2车间生产条码\20150621\BZ.mdb", False, False, "MS Access;pwd=123")
Set RS1 = DB1.OpenRecordset(name:="数据源", Type:=dbOpenDynaset)
RS1.FindFirst "序号=" & TextBox1.Value & ""
If RS1.NoMatch = True Then
MsgBox "对不起,没有查到序号为:" & TextBox1.Value & " 的相关信息"
RS1.Close
Exit Sub
Else
TextBox2.Value = RS1.Fields("单号").Value
TextBox3.Value = RS1.Fields("长").Value
TextBox4.Value = RS1.Fields("宽").Value
TextBox5.Value = RS1.Fields("玻璃").Value
TextBox6.Value = RS1.Fields("锁孔信息").Value
TextBox7.Value = RS1.Fields("锁孔贴码").Value
TextBox8.Value = RS1.Fields("提货日期").Value
End If
RS1.Close
Set RS1 = Nothing
Set DB1 = Nothing
End If
Exit Sub '正常执行结束,跳出 sub
100:
MsgBox Err.Description, 1 + 16, "系统提示"
End Sub
.FindFirst提示未找到方法或数据成员 展开
On Error GoTo 100
If TextBox1.Text = "" Then
MsgBox "请输入序号", 1 + 16, "出错提示"
TextBox1.SetFocus
Else
Dim RS1 As Recordset
Dim DB1 As Database
Set DB1 = OpenDatabase("\\192.168.1.254\2车间生产条码\20150621\BZ.mdb", False, False, "MS Access;pwd=123")
Set RS1 = DB1.OpenRecordset(name:="数据源", Type:=dbOpenDynaset)
RS1.FindFirst "序号=" & TextBox1.Value & ""
If RS1.NoMatch = True Then
MsgBox "对不起,没有查到序号为:" & TextBox1.Value & " 的相关信息"
RS1.Close
Exit Sub
Else
TextBox2.Value = RS1.Fields("单号").Value
TextBox3.Value = RS1.Fields("长").Value
TextBox4.Value = RS1.Fields("宽").Value
TextBox5.Value = RS1.Fields("玻璃").Value
TextBox6.Value = RS1.Fields("锁孔信息").Value
TextBox7.Value = RS1.Fields("锁孔贴码").Value
TextBox8.Value = RS1.Fields("提货日期").Value
End If
RS1.Close
Set RS1 = Nothing
Set DB1 = Nothing
End If
Exit Sub '正常执行结束,跳出 sub
100:
MsgBox Err.Description, 1 + 16, "系统提示"
End Sub
.FindFirst提示未找到方法或数据成员 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |