我有以下代码,它应该遍历项目中的所有表单,并给出一个包含每个表单设置的消息框。我知道循环是正确的,因为我在其他地方使用了循环并且我只是复制了它。为什么消息框是空白的?
For Each frm In CurrentProject.AllForms
DoCmd.OpenForm frm.Name, acDesign
mess = "Form: " & frm.Name & vbCrLf & " Allow Addition: " & CStr(frm.AllowAdditions) & vbCrLf & "Allow Deletions: " & CStr(frm.AllowDeletions) & vbCrLf & " Allow Edit: " & CStr(frm.AllowEdits)
MsgBox (mess)
DoCmd.Close acForm, frm.Name, acSaveYes
Next frm
Set frm = Nothing
借助 Remou 的提示,我得到了以下工作:
For Each frm In CurrentProject.AllForms
DoCmd.OpenForm frm.Name, acDesign
Set frm = Forms(frm.Name)
mess = "Form: " & frm.Name & vbCrLf & " Allow Addition: " & CStr(frm.AllowAdditions) & vbCrLf & "Allow Deletions: " & CStr(frm.AllowDeletions) & vbCrLf & " Allow Edit: " & CStr(frm.AllowEdits)
MsgBox (mess)
DoCmd.Close acForm, frm.Name, acSaveNo
Next frm
Set frm = Nothing