首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >如何在visual basic中转到下一个窗体?

如何在visual basic中转到下一个窗体?
EN

Stack Overflow用户
提问于 2018-06-09 03:07:20
回答 1查看 56关注 0票数 -2

我正在尝试进入excel宏的下一个表单。

现在,我有一个具有用户名和密码的登录表单,当我按下login时,它将转到下一个表单。

但是当我转到我的下一个表单并在其中键入信息时,它将关闭,并且不会弹出下一个论坛。

有人能给我解释一下我哪里做错了吗?为什么我的下一个表单不弹出?

代码语言:javascript
复制
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
EN

回答 1

Stack Overflow用户

发布于 2018-06-09 04:27:01

我使用了Formname1.Hide Formname2.Show

这似乎解决了我的问题。谢谢你们的帮助。对不起,我对这个网站很陌生。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50767012

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档