That doesn't seem to work. Also, I'm using Form.Show() from another form which is firing up the Load event so that's pretty much the same thing. Anyway, I'm still getting the same error.
A number of reasons. Firstly, if a person has not got permissions to use the form. Also, in the case of a data maintenance form, if the user asks for a non-existent record. There are a few other reasons but you see what I mean.
Why not test the permissions before you load the form?
--------------------------------------
"We are star-stuff. We are the universe made manifest trying to figure itself out."
-- Delenn in Babylon 5 - "A Distant Star"
We also had the same kind of problem and the simple answer is, No we can not use Me.Close() at the load event and it is not a permission issue, so what we did was we created two functions on the base class, one is preLoad and the other is postLoad and we moved all the logic from the Load event to the preload and if everything is succesfull then we set a flag, something like isErrorOnPreLoad depending on the way how preLoad went. And in postLoad we check to see if the flag is TRUE, if so don't close the window, else close the window in postLoad function. So the code would be like this,
Dim oFrm as New frmMain
With ofrm
.preLoad()
.Show()
.postLoad()
End With
And if there was an error in preLoad, then we hide the window and postLoad will then close the window later. It depends on how you want to implement this, because the flag which I was talking about that can be an attribute and can be done this way as well.
Dim oFrm as New frmMain
With ofrm
.preLoad()
IF .isErrorOnPreLoad then Return
.Show()
End With
This way we eleminated postLoad and will work for any type of forms like sheets, response etc. I think this might help you little bit.
Kris11, thanks you. It's almost exactly what I was looking for. What I have done is put a routine in the base class similar to your 'preload' which will do a bunch of checks and then call the show method if everything is okay. This way saves me showing the form at all if the user has no permissions for it.
Thanks again for your help.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.