mloucel
Member
- Local time
- Yesterday, 20:16
- Joined
- Aug 5, 2020
- Messages
- 309
Hello Gurus..
I have a form that when opened Opens a Sub Form containing some useful data for the user, I really as ADMIN do not need that data, and interferes when I try to perform maintenance on the DB, for some reason even when I close the Form something is left Open and the laccdb file is never deleted, I did a reasearch even in this forums but nothing I did worked, I found some great code:
But damn thing never closes, but I noticed that when I go to Design View, the damn thing closes, so I had an Idea, create 2 Forms 1 with the Original form for the users and 1 for me the ADMIN, that did not have the sub-form, and it works fine.
BUT.
What if I can open the original form and before it opens, ask:
Is this the superadmin
if Yes
then Do Not Open the Sub-Form and Hide it
else
Continue Normally
end if
Is this possible? and if so, what type of VBA Code should I use?
Thanks..
I have a form that when opened Opens a Sub Form containing some useful data for the user, I really as ADMIN do not need that data, and interferes when I try to perform maintenance on the DB, for some reason even when I close the Form something is left Open and the laccdb file is never deleted, I did a reasearch even in this forums but nothing I did worked, I found some great code:
Code:
With CurrentData
' "Tables"
For Each aob In .AllTables
If aob.IsLoaded Then
DoCmd.Close acTable, aob.Name, acSaveYes
End If
Next aob
' "Queries"
For Each aob In .AllQueries
If aob.IsLoaded Then
DoCmd.Close acQuery, aob.Name, acSaveYes
End If
Next aob
End With
But damn thing never closes, but I noticed that when I go to Design View, the damn thing closes, so I had an Idea, create 2 Forms 1 with the Original form for the users and 1 for me the ADMIN, that did not have the sub-form, and it works fine.
BUT.
What if I can open the original form and before it opens, ask:
Is this the superadmin
if Yes
then Do Not Open the Sub-Form and Hide it
else
Continue Normally
end if
Is this possible? and if so, what type of VBA Code should I use?
Thanks..