chuckcoleman
Registered User.
- Local time
- Today, 07:08
- Joined
- Aug 20, 2010
- Messages
- 380
Hi,
I have some VBA code that runs when a form opens. The purpose of the code is to make visible or invisible 17 different Command buttons on the form. The reason for this has to giving certain users the ability to run certain reports and other users they can't. It takes a couple of seconds to load and I'm sure there is a way to improve this. My understanding is that DLookUp is typically slow which is probably part of the problem. The code below is for just two of the 17 Command buttons:
If DLookup("ControlAuto", "[Permissions Query]", "[ControlAuto] = " & 10 & "") = 10 Then
Me.PrtPreviewBalanceDueSummary.Visible = True
Else
Me.PrtPreviewBalanceDueSummary.Visible = False
End If
If DLookup("ControlAuto", "[Permissions Query]", "[ControlAuto] = " & 11 & "") = 11 Then
Me.PrtPreviewBalanceDueByLocWDetail.Visible = True
Else
Me.PrtPreviewBalanceDueByLocWDetail.Visible = False
End If
In essence, there are 17 DLookUp's. I'm not sure if using a loop is better than the If-Then or something else.
Please share your thoughts.
Thanks,
Chuck
I have some VBA code that runs when a form opens. The purpose of the code is to make visible or invisible 17 different Command buttons on the form. The reason for this has to giving certain users the ability to run certain reports and other users they can't. It takes a couple of seconds to load and I'm sure there is a way to improve this. My understanding is that DLookUp is typically slow which is probably part of the problem. The code below is for just two of the 17 Command buttons:
If DLookup("ControlAuto", "[Permissions Query]", "[ControlAuto] = " & 10 & "") = 10 Then
Me.PrtPreviewBalanceDueSummary.Visible = True
Else
Me.PrtPreviewBalanceDueSummary.Visible = False
End If
If DLookup("ControlAuto", "[Permissions Query]", "[ControlAuto] = " & 11 & "") = 11 Then
Me.PrtPreviewBalanceDueByLocWDetail.Visible = True
Else
Me.PrtPreviewBalanceDueByLocWDetail.Visible = False
End If
In essence, there are 17 DLookUp's. I'm not sure if using a loop is better than the If-Then or something else.
Please share your thoughts.
Thanks,
Chuck