表单详细信息部分在VBA中更改后加载空白

时间:2015-08-25 15:23:52

标签: forms vba access-vba ms-access-2013

我最近在表单的VBA中进行了一些更改,现在Form in Form视图的Details部分加载了空白。我可以看到标题,并且底部列出了记录数,但“详细信息”部分现在加载空白。我的假设是VBA代码会导致这种情况发生,因为我没有更改任何表单设置。

我在向表单区域添加一些新功能时遇到了一些麻烦。一切都很顺利。然后我复制了我使用的代码并对其进行了修改,以便对表单的不同部分执行相同的操作。对于上下文,此表单只是一个Review页面,它将数据从多个表中提取到摘要页面中。这在以前不是问题,我在后面确认所有设置都是相同的,备份没有这个问题。备份和当前表单的唯一区别是添加了控件和命令按钮,以及一些VBA。然而备份加载正确,我的新文件没有。我已经复制了下面的VBA以防万一因为这个问题可能会引起你的注意。我确实在Form Load和Current部分添加了VBA,但它只是已经存在的代码重复。我复制了引用软件和软件的代码来说硬件和硬件。我不确定为什么这可能导致问题。所有引用软件的代码都经过测试并且工作得很满意,因此我将所有代码都复制到硬件中。在某个地方就是问题所在。我已经复制了整个表单的所有VBA。抱歉这个长度,但我认为它可以提供信息。您可能会注意到草率工作或代码使用效率低下,因为我对此仍然是新手,但希望它有意义。如果我能澄清任何事情或解释我试图通过特定功能完成的事情,请不要犹豫。

我非常感谢任何帮助。

Option Compare Database

Private Sub cmdAddSWRev_Click()

Me.lstSWRevAdd.Visible = True
Me.lstSWRevDateAdd.Visible = True
Me.lstSWRevNotesAdd.Visible = True
Me.lblSwRevAdd.Visible = True
Me.lblSWRevDateAdd.Visible = True
Me.lblSWRevNotesAdd.Visible = True

Me.lstSWRev.Visible = False
Me.lstSWRevDate.Visible = False
Me.lstSWRevNotes.Visible = False
Me.lblSWRev.Visible = False
Me.lblSWRevDate.Visible = False
Me.lblSWRevNotes.Visible = False

Me.cmdSaveSWRev.Visible = True

End Sub


Private Sub cmdHWRevAdd_Click()

Me.lstHWRevAdd.Visible = True
Me.lstHWRevDateAdd.Visible = True
Me.lstHWRevNotesAdd.Visible = True
Me.lblHWRevAdd.Visible = True
Me.lblHWRevDateAdd.Visible = True
Me.lblHWRevNotesAdd.Visible = True

Me.lstHWRev.Visible = False
Me.lstHWRevDate.Visible = False
Me.lstHWRevNotes.Visible = False
Me.lblHWRev.Visible = False
Me.lblHWRevDate.Visible = False
Me.lblHWRevNotes.Visible = False

Me.cmdSaveHWRev.Visible = True

End Sub

Private Sub cmdSaveSWRev_Click()

'Create an entry in Software Revisions

   Dim SerialNumberDatabase As DAO.Database
   Dim tblSoftwareRevisions As DAO.Recordset


   Set SerialNumberDatabase = CurrentDb
   Set tblSoftwareRevisions = SerialNumberDatabase.OpenRecordset("tblSoftwareRevisions")

   tblSoftwareRevisions.AddNew
   tblSoftwareRevisions("SoftwareRevision").Value = Me.lstSWRevAdd
   tblSoftwareRevisions("Assembly").Value = Me.PartNumber_tblUnits
   tblSoftwareRevisions("SWRevDate").Value = Me.lstSWRevDateAdd
   tblSoftwareRevisions("Notes").Value = Me.lstSWRevNotesAdd
   tblSoftwareRevisions.Update
   tblSoftwareRevisions.Close

'Add the new Software Revision ID to the existing unit in tblUnits by editing the Null SoftwareID field

 Dim tblUnits As DAO.Recordset
 Set tblUnits = SerialNumberDatabase.OpenRecordset("tblUnits")

 tblUnits.MoveFirst
   Do Until tblUnits.EOF
      If tblUnits!SerialNumber = Me.lstSerialNumber And tblUnits!PartNumber = Me.lstPartNumber Then
         tblUnits.Edit
         tblUnits!SoftwareID = DMax("SWRevID", "tblSoftwareRevisions")
         tblUnits.Update
      End If
      tblUnits.MoveNext
   Loop

   MsgBox ("The Software Revision has been added for this unit")


End Sub
Private Sub cmdSaveHWRev_Click()

'Create an entry in Software Revisions

   Dim SerialNumberDatabase As DAO.Database
   Dim tblHardwareRevisions As DAO.Recordset


   Set SerialNumberDatabase = CurrentDb
   Set tblHardwareRevisions =     SerialNumberDatabase.OpenRecordset("tblHardwareRevisions")

   tblHardwareRevisions.AddNew
   tblHardwareRevisions("HardwareRevision").Value = Me.lstHWRevAdd
   tblHardwareRevisions("Assembly").Value = Me.PartNumber_tblUnits
   tblHardwareRevisions("HWRevDate").Value = Me.lstHWRevDateAdd
   tblHardwareRevisions("Notes").Value = Me.lstHWRevNotesAdd
   tblHardwareRevisions.Update
   tblHardwareRevisions.Close

'Add the new Software Revision ID to the existing unit in tblUnits by editing the Null SoftwareID field

 Dim tblUnits As DAO.Recordset
 Set tblUnits = SerialNumberDatabase.OpenRecordset("tblUnits")

 tblUnits.MoveFirst
   Do Until tblUnits.EOF
      If tblUnits!SerialNumber = Me.lstSerialNumber And tblUnits!PartNumber = Me.lstPartNumber Then
         tblUnits.Edit
         tblUnits!HardwareID = DMax("HWRevID", "tblHardwareRevisions")
         tblUnits.Update
      End If
      tblUnits.MoveNext
   Loop
        tblUnits.Close
   MsgBox ("The Hardware Revision has been added for this unit")


End Sub
Private Sub cmdSearch_Click()

DoCmd.ShowAllRecords
DoCmd.RunCommand acCmdFind


End Sub

Private Sub Form_Current()

Me.lstUnitBuiltDate.Requery

If Me.txtSerialCount.Value > 1 Then
Me.tblReportedIssues_subform_Label.Visible = True
Me.tblReportedIssues_subform.Visible = True
Else
Me.tblReportedIssues_subform_Label.Visible = False
Me.tblReportedIssues_subform.Visible = False
End If

If Me.txtRMACount.Value > 1 Then
Me.tblReportedIssues_subform1_Label.Visible = True
Me.tblReportedIssues_subform1.Visible = True
Else
Me.tblReportedIssues_subform1_Label.Visible = False
Me.tblReportedIssues_subform1.Visible = False
End If

If Me.lstSerialNumber.Value < 1 Then
Me.txtSerialNote.Visible = True
Else
Me.txtSerialNote.Visible = False
End If

Me.lstSWRevAdd.Visible = False
Me.lstSWRevDateAdd.Visible = False
Me.lstSWRevNotesAdd.Visible = False
Me.lblSwRevAdd.Visible = False
Me.lblSWRevDateAdd.Visible = False
Me.lblSWRevNotesAdd.Visible = False
Me.cmdSaveSWRev.Visible = False

Me.lstSWRev.Visible = True
Me.lstSWRevDate.Visible = True
Me.lstSWRevNotes.Visible = True
Me.lblSWRev.Visible = True
Me.lblSWRevDate.Visible = True
Me.lblSWRevNotes.Visible = True

Me.lstHWRevAdd.Visible = False
Me.lstHWRevDateAdd.Visible = False
Me.lstHWRevNotesAdd.Visible = False
Me.lblHWRevAdd.Visible = False
Me.lblHWRevDateAdd.Visible = False
Me.lblHWRevNotesAdd.Visible = False
Me.cmdSaveHWRev.Visible = False

Me.lstHWRev.Visible = True
Me.lstHWRevDate.Visible = True
Me.lstHWRevNotes.Visible = True
Me.lblHWRev.Visible = True
Me.lblHWRevDate.Visible = True
Me.lblHWRevNotes.Visible = True

End Sub

Private Sub Form_Load()

Me.lstSWRevAdd.Visible = False
Me.lstSWRevDateAdd.Visible = False
Me.lstSWRevNotesAdd.Visible = False
Me.lblSwRevAdd.Visible = False
Me.lblSWRevDateAdd.Visible = False
Me.lblSWRevNotesAdd.Visible = False
Me.cmdSaveSWRev.Visible = False

Me.lstSWRev.Visible = True
Me.lstSWRevDate.Visible = True
Me.lstSWRevNotes.Visible = True
Me.lblSWRev.Visible = True
Me.lblSWRevDate.Visible = True
Me.lblSWRevNotes.Visible = True

Me.lstHWRevAdd.Visible = False
Me.lstHWRevDateAdd.Visible = False
Me.lstHWRevNotesAdd.Visible = False
Me.lblHWRevAdd.Visible = False
Me.lblHWRevDateAdd.Visible = False
Me.lblHWRevNotesAdd.Visible = False
Me.cmdSaveHWRev.Visible = False

Me.lstHWRev.Visible = True
Me.lstHWRevDate.Visible = True
Me.lstHWRevNotes.Visible = True
Me.lblHWRev.Visible = True
Me.lblHWRevDate.Visible = True
Me.lblHWRevNotes.Visible = True

Me.lstUnitBuiltDate.Requery

End Sub

Private Sub lstRMA_Click()

MsgBox "This cannot be Edited or Altered", vbCritical, "Field Locked"

End Sub

Private Sub tblReportedIssues_subform_Enter()

MsgBox "This cannot be Edited or Altered. If you would like to review a listed RMA, please use the Search or Navigation buttons to locate it.", vbCritical, "Field Locked"

End Sub

如果重要,表单有一个记录源“SELECT tblReportedIssues。*,tblUnits.Notes,tblUnits.SerialNumber AS SerialNumber_tblUnits,tblUnits.PartNumber AS PartNumber_tblUnits FROM tblUnits INNER JOIN(tblRMA INNER JOIN tblReportedIssues on tblRMA.RMANumber = tblReportedIssues .RMA)ON(tblUnits.PartNumber = tblReportedIssues.PartNumber)AND(tblUnits.SerialNumber = tblReportedIssues.SerialNumber);“

使用如下设置: 记录集:动态集 获取默认值:是 过滤:(空白) 负载过滤:否 订购方式:(空白) 负载订单:没有 等待后处理:否 数据输入:没有 允许添加:否 允许删除:否 允许编辑:是的 允许过滤器:是的 记录锁定:无锁定

这些设置和记录源在我的备份文件上工作,因为它们允许正确加载所有内容。

1 个答案:

答案 0 :(得分:0)

我是个白痴。经过大量调查后,我似乎意外地在设计模式中选择了细节栏,并在我试图隐藏其他控件时将其可见性更改为“否”。