为什么我的按钮表格无法正常工作



在此之前,我已经在这里问过,但是我仍然没有修复它。我尝试各种可能的方法,但仍然无法解决问题。

我将尝试再次解释。基本上,我有具有"活动"状态的文档列表。因此,我的按钮在"批处理"视图上。我的按钮过程从"计算机"中的所有文档中开始查看是否存在"锁定"状态。如果任何文档具有"锁定"状态,则退出子,否则继续处理。流程继续是首先设置批处理号。然后在"计算机"中创建复制文档。复制文档将具有状态"草稿",当前文档将替换为"锁定"。此过程将继续用于所有文档。

所以在这里我的lotusscript按钮。

Set db = session.CurrentDatabase
Set uiview = ws.CurrentView
Set uidoc = ws.CurrentDocument
Set dialogDoc = uidoc.Document
Set view = db.GetView("Computer")
Set doc = view.GetFirstDocument
While Not (doc Is Nothing)
    If doc.PStatus(0) = "Lock" Then
        Msgbox "Complete PC Inspection first!"
        Exit Sub
    Else
        answer% = Messagebox("Do you confirm?")
        If Not answer% = 6 Then
            Msgbox("Process Incomplete")
            Exit Sub
        Else
            dialogDoc.Form = "BatchInfo"
            Call uidoc.FieldSetText("SaveOptions", "1")
            Call uidoc.Save
            While Not (doc Is Nothing)
                If doc.PStatus(0) = "Active" Then
            '-----create new copy document-----'
                    Set newdoc = doc.CopyToDatabase(db)
                    newdoc.PBatchNo = dialogDoc.BBatchNo(0)
                    newdoc.PStatus = "Draft"
                    Call newdoc.Save(True, False)
                    doc.PStatus = "Lock"
                    Call doc.ComputeWithForm(False,False)
                    Call doc.save(True,False)
                End If
                Set doc = view.GetNextDocument(doc)
            Wend
            Messagebox("Process completed.")
        End If
    End If
    Exit Sub
Wend

现在,"计算机"中的所有文档都将具有状态"锁",因此,当我再次单击按钮时,它应该直接退出子。

首次测试:因此,现在,我将从"锁定"中更改"计算机"列表中的任何文档的状态。除第一个文档以外的任何文档。然后,我将返回"批处理"视图和单击按钮,它显示MSGBOX"首先完成PC检查!"。这意味着没有问题

第二个测试:所以现在,我尝试第二次测试。此测试与第一次测试相似,但是对于此测试,我将在"计算机"视图中更改文档状态。然后,我返回"批处理"视图和单击按钮,它忽略了消息,然后转到第14行,即"答案%= MessageBox("您确认吗?"("。它不应该跳到此行,因为在"计算机"视图中,仍然有"锁定"状态的文档。

我尝试了任何可能的方法,但我无法成功。有人可以帮助我的问题吗?对此,我真的非常感激。谢谢

从您对要做的事情的描述来判断,我认为您需要第一个时刻。

Set db = session.CurrentDatabase
Set uiview = ws.CurrentView
Set uidoc = ws.CurrentDocument
Set dialogDoc = uidoc.Document
Set view = db.GetView("Computer")
'First run through the loop checks if ANY doc has PStatus = "Lock"
Set doc = view.GetFirstDocument
While Not (doc Is Nothing)
    If doc.PStatus(0) = "Lock" Then
        Msgbox "Complete PC Inspection first!"
        Exit Sub
    End If
    Set doc = view.getNextDocument(doc) 'add (doc)
Wend
'Not sure what this is all about, but I'll leave it in
answer% = Messagebox("Do you confirm?")
If Not answer% = 6 
    Msgbox("Process Incomplete")
    Exit Sub
Else
    'I've no idea what the next three lines are for, but I'll leave them alone
    dialogDoc.Form = "BatchInfo"
    Call uidoc.FieldSetText("SaveOptions", "1")
    Call uidoc.Save
    'Loop through the view again, creating copies and setting status to Lock
    Set doc = view.GetFirstDocument 'Add this line
    While Not (doc Is Nothing)
        If doc.PStatus(0) = "Active" Then
            '-----create new copy document-----'
            Set newdoc = doc.CopyToDatabase(db)
            newdoc.PBatchNo = dialogDoc.BBatchNo(0)
            newdoc.PStatus = "Draft"
            Call newdoc.Save(True, False)
            doc.PStatus = "Lock"
            Call doc.ComputeWithForm(False,False)
            Call doc.save(True,False)
        End If
        Set doc = view.GetNextDocument(doc)
     Wend
End If
Messagebox("Process completed.")

我希望这会有所帮助。我认为您的问题是您以为您正在浏览整个视图,以寻找带有pstatus =" lock"的文档,但是因为您的Wend在代码末尾是正确的,并且没有View.GetNextDocument(DOC((,这根本没有发生。

最新更新