我的子表单在主表单上显示为空白

时间:2019-08-16 03:04:26

标签: access-vba

我有三个不同的子窗体,它们从两个不同的表中获取信息。我正在使用查询作为所有子窗体的控制源。我已经将变量传递给主表单,并进行了查询以从主表单中提取值。加载表单时,子表单为空白,但是如果进入设计视图并切换回表单视图,则表单已完成。不知道这里发生了什么。

 Private Sub OpenReports_Click()

 Dim MonDate As Date, TueDate As Date, WedDate As Date, ThuDate As Date, F 
 FriDate As Date, SatDate As Date, SunDate As Date

 MonDate = Me.StartDate.Value
 TueDate = DateAdd("d", 1, MonDate)
 WedDate = DateAdd("d", 2, MonDate)
 ThuDate = DateAdd("d", 3, MonDate)
 FriDate = DateAdd("d", 4, MonDate)
 SatDate = DateAdd("d", 5, MonDate)
 SunDate = DateAdd("d", 6, MonDate)

 If Form_ReportsMenu.Sun.Value = True Then
     DoCmd.OpenForm "FRM_Sun_Challenges", acNormal, , , acFormEdit
     Form_FRM_Sun_Challenges.UserID.Value = Me.UserID.Value
     Form_FRM_Sun_Challenges.WeekNumber.Value = Me.WeekNumber.Value
     Form_FRM_Sun_Challenges.FullName.Value = Me.FullName.Value
     Form_FRM_Sun_Challenges.StartDate.Value = SunDate
 End If

 If Form_ReportsMenu.Sat.Value = True Then
     DoCmd.OpenForm "FRM_Sat_Challenges", acNormal, , , acFormEdit
     Form_FRM_Sat_Challenges.UserID.Value = Me.UserID.Value
     Form_FRM_Sat_Challenges.WeekNumber.Value = Me.WeekNumber.Value
     Form_FRM_Sat_Challenges.FullName.Value = Me.FullName.Value
     Form_FRM_Sat_Challenges.StartDate.Value = SatDate
 End If

 If Form_ReportsMenu.Fri.Value = True Then
     DoCmd.OpenForm "FRM_Fri_Challenges", acNormal, , , acFormEdit
     Form_FRM_Fri_Challenges.UserID.Value = Me.UserID.Value
     Form_FRM_Fri_Challenges.WeekNumber.Value = Me.WeekNumber.Value
     Form_FRM_Fri_Challenges.FullName.Value = Me.FullName.Value
     Form_FRM_Fri_Challenges.StartDate.Value = FriDate
 End If

 If Form_ReportsMenu.Thu.Value = True Then
     DoCmd.OpenForm "FRM_Thu_Challenges", acNormal, , , acFormEdit
     Form_FRM_Thu_Challenges.UserID.Value = Me.UserID.Value
     Form_FRM_Thu_Challenges.WeekNumber.Value = Me.WeekNumber.Value
     Form_FRM_Thu_Challenges.FullName.Value = Me.FullName.Value
     Form_FRM_Thu_Challenges.StartDate.Value = ThuDate
 End If

 If Form_ReportsMenu.Wed.Value = True Then
     DoCmd.OpenForm "FRM_Wed_Challenges", acNormal, , , acFormEdit
     Form_FRM_Wed_Challenges.UserID.Value = Me.UserID.Value
     Form_FRM_Wed_Challenges.WeekNumber.Value = Me.WeekNumber.Value
     Form_FRM_Wed_Challenges.FullName.Value = Me.FullName.Value
     Form_FRM_Wed_Challenges.StartDate.Value = WedDate
 End If

 If Form_ReportsMenu.Tue.Value = True Then
     DoCmd.OpenForm "FRM_Tue_Challenges", acNormal, , , acFormEdit
     Form_FRM_Tue_Challenges.UserID.Value = Me.UserID.Value
     Form_FRM_Tue_Challenges.WeekNumber.Value = Me.WeekNumber.Value
     Form_FRM_Tue_Challenges.FullName.Value = Me.FullName.Value
     Form_FRM_Tue_Challenges.StartDate.Value = TueDate
 End If

 If Form_ReportsMenu.Mon.Value = True Then
     'DoCmd.OpenQuery "MON_STChallengesQ", , acEdit
     DoCmd.OpenForm "FRM_Mon_Challenges", acNormal, , , acFormEdit
     Form_FRM_Mon_Challenges.UserID.Value = Me.UserID.Value
     Form_FRM_Mon_Challenges.WeekNumber.Value = Me.WeekNumber.Value
     Form_FRM_Mon_Challenges.FullName.Value = Me.FullName.Value
     Form_FRM_Mon_Challenges.StartDate.Value = MonDate
 End If

 DoCmd.Close acForm, "ReportsMenu"

 End Sub

我试图在打开表单之前调用查询,但是没有用。这一定很简单,因为就像我之前说的那样。我只是离开了表单视图,然后又回到了它,子表单已经完成。查询正在运行,但在加载表单时未获取数据。

0 个答案:

没有答案