我正在尝试使用excel宏的下一个表单
现在我有一个具有用户名和密码的登录表单 当我按下登录时它会运行到下一个表格。
但是当我转到下一个表单并在其中键入信息时,它会关闭并且不会启动下一个论坛。
有人可以向我解释我做错了什么吗?为什么我的下一个表格不会弹出?
Private Sub cmdAdd_Click()
'Dim iRow As Long
'Dim ws As Worksheet
Set ws = Worksheets("D544 Back Panel")
'find first empty row in database
iRow = ws.Cells.Find(What:="*", SearchOrder:=xlRows, _
SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1
'check for a part number
If Trim(Me.txtPrd.Value) = "" Then
Me.txtPrd.SetFocus
MsgBox "Please enter a Production Number"
Exit Sub
End If
'copy the data to the database
'use protect and unprotect lines,
' with your password
' if worksheet is protected
With ws
' .Unprotect Password:="Password"
.Cells(iRow, 1).Value = Me.txtDate.Value
.Cells(iRow, 2).Value = Me.txtHrs.Value
.Cells(iRow, 3).Value = Me.txtPrd.Value
.Cells(iRow, 4).Value = Me.txtSrp.Value
.Cells(iRow, 5).Value = Me.txtOper.Value
' .Protect Password:="Password"
End With
'clear the data
Me.txtDate.Value = ""
Me.txtHrs.Value = ""
Me.txtPrd.Value = ""
Me.txtSrp.Value = ""
Me.txtOper.Value = ""
Me.txtPrd.SetFocus
Unload Me
End Sub
Private Sub cmdSubmit_Click()
'Dim iRow As Long
'Dim ws As Worksheet
Set ws = Worksheets("Scrap")
'find first empty row in database
iRow = ws.Cells.Find(What:="*", SearchOrder:=xlRows, _
SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1
'check for a part number
If Trim(Me.txtPress.Value) = "" Then
Me.txtPress.SetFocus
MsgBox "Please enter press scrap"
Exit Sub
End If
'copy the data to the database
'use protect and unprotect lines,
' with your password
' if worksheet is protected
With ws
' .Unprotect Password:="Password"
.Cells(iRow, 1).Value = Me.txtDelam.Value
.Cells(iRow, 2).Value = Me.txtCuts.Value
.Cells(iRow, 3).Value = Me.txtBurns.Value
.Cells(iRow, 4).Value = Me.txtDents.Value
.Cells(iRow, 5).Value = Me.txtStaple.Value
.Cells(iRow, 6).Value = Me.txtGlue.Value
.Cells(iRow, 7).Value = Me.txtPress.Value
' .Protect Password:="Password"
End With
'clear the data
Me.txtDelam.Value = ""
Me.txtCuts.Value = ""
Me.txtBurns.Value = ""
Me.txtDents.Value = ""
Me.txtStaple.Value = ""
Me.txtGlue.Value = ""
Me.txtPress.Value = ""
Me.txtPress.SetFocus
Unload Me
End Sub
答案 0 :(得分:0)
这似乎解决了我的问题。谢谢你的帮助。对不起,我对这个网站很新。