找到原因了,代码改下面就实现了
If User.Type = 3 Then
For Each c As Winform.Control In e.Form.Controls
c.Visible = False
Forms("主界面").Controls("主界面").Visible = True
'标签控件
Forms("主界面").Controls("Label01").Visible = True
Forms("主界面").Controls("Label1").Visible = True
Forms("主界面").Controls("Label10").Visible = True
Forms("主界面").Controls("Label11").Visible = True
Forms("主界面").Controls("Label12").Visible = True
Forms("主界面").Controls("Label13").Visible = True
Forms("主界面").Controls("Label4").Visible = True
Forms("主界面").Controls("Label5").Visible = True
Forms("主界面").Controls("Label6").Visible = True
Forms("主界面").Controls("Label7").Visible = True
Forms("主界面").Controls("Label8").Visible = True
Forms("主界面").Controls("Label9").Visible = True
'日期控件
Forms("主界面").Controls("StartDate").Visible = True
Forms("主界面").Controls("EndDate").Visible = True
Forms("主界面").Controls("StartDate1").Visible = True
Forms("主界面").Controls("EndDate1").Visible = True
Forms("主界面").Controls("StartDate2").Visible = True
Forms("主界面").Controls("EndDate2").Visible = True
Forms("主界面").Controls("StartDate3").Visible = True
Forms("主界面").Controls("EndDate3").Visible = True
'文本框控件
Forms("主界面").Controls("cmbCustomer").Visible = True
Forms("主界面").Controls("pr").Visible = True
Forms("主界面").Controls("smartI").Visible = True
Forms("主界面").Controls("TextBox1").Visible = True
Dim dr1 As DataRow = DataTables("Users").Find("Name = '" & User.Name & "'")
For Each dr2 As DataRow In DataTables("授权表").Select("(用户组 not like '%"&dr1("roleCode")& "%' or 用户组 is null) and 控件名称 is null ")
Forms("主界面").Controls(dr2("窗体")).TabPages(dr2("页面名称")).Visible = False
Next
For Each dr As DataRow In DataTables("授权表").Select("用户组 like '%"&dr1("roleCode")& "%'and 控件<>''") '
Forms("主界面").Controls(dr("控件")).Visible = True
Next
Next
End If