DanG
Registered User.
- Local time
- Today, 09:58
- Joined
- Nov 4, 2004
- Messages
- 477
As my main form loads (onload), I would like it to check for users (have that solved) and if thee user is #1 level keep loading the current form (frmMSEntry). If the user lever is anything else but #1, I want it to load another form (frmReportCentral) using VBA.
I have it for the most part and have isolated the problem to frmMSEntry. When this form closes I get an "Enter Perameter Value" for "Forms!frmMSREntry!ServiceRequested" which is a field on frmMSREntry. During normal day to day use I have no problem whith this field, only in trying to do what I am doing here is it a problem. But there is a lot going on with this field behind the scenes (VBA). I think in the end if I were to guess I'd day it was an event problem, because I really want to run the test (VBA) before anythings starts to load?
Hopefully this is enough info?
I appreciate any suggestions!
Thank you
frmMSREntry Code (just coded for testing, not full featured yet):
ServiceRequested field VBA for the "AfterUpdate" event:
I have it for the most part and have isolated the problem to frmMSEntry. When this form closes I get an "Enter Perameter Value" for "Forms!frmMSREntry!ServiceRequested" which is a field on frmMSREntry. During normal day to day use I have no problem whith this field, only in trying to do what I am doing here is it a problem. But there is a lot going on with this field behind the scenes (VBA). I think in the end if I were to guess I'd day it was an event problem, because I really want to run the test (VBA) before anythings starts to load?
Hopefully this is enough info?
I appreciate any suggestions!
Thank you
frmMSREntry Code (just coded for testing, not full featured yet):
Code:
Private Sub Form_Open(Cancel As Integer)
If CurrentProject.AllForms("frmCurrentUserHidden").IsLoaded Then
Dim level As String
level = Nz(Forms.frmCurrentUserHidden!UserLevel)
Select Case level
Case "1"
DoCmd.Close acForm, "frmMSREntry"
Case "4"
MsgBox ("You are not #1")
Case Else
MsgBox "You Are Not Authorized To Enter This Area", vbCritical
End Select
End If
End Sub
ServiceRequested field VBA for the "AfterUpdate" event:
Code:
Select Case Me.ServiceRequested.Value
Case 3, 11
Me.ServiceType.Enabled = True
Me.Campaign.Enabled = False
Me.Campaign.Value = Null
Me.CampReturnScreen.Visible = False
Case 2
Me.ServiceType.Enabled = True
Me.CampReturnScreen.Visible = False
Me.Campaign.Enabled = False
Me.Campaign.Value = Null
Case 10
Me.Campaign.Enabled = True
Me.ServiceType.Enabled = False
Me.ServiceType.Value = Null
Me.CampReturnScreen.Visible = True
Case Else
Me.ServiceType.Enabled = False
Me.Campaign.Enabled = False
Me.ServiceType.Value = Null
Me.Campaign.Value = Null
Me.CampReturnScreen.Visible = False
End Select
If Me.ServiceRequested <> 10 Then
DoCmd.SetWarnings False
DoCmd.OpenQuery ("qryPurgeCampaignReturned")
Me.CampReturnScreen.Requery
DoCmd.SetWarnings True
End If