Disabling / Hiding X with pbool function (referring to other post)

Ally

Registered User.
Local time
Today, 00:03
Joined
Sep 18, 2001
Messages
617
I've used the function as discussed in this post but am not getting quite what I need.

It's disabling the use of the x in the database window, but not in the forms I need it. The database window is not visible to the users, and I would generally need to use this x button. I am wanting to disable the x in the forms so that users have to use the buttons I've put there for them. I've disabled it in the properties, but when maximized, this doesn't work.

Does anyone know what I'm doing wrong please?

I've got:
  • frmHidden, with the code on Unload
  • module, with the code suggested
  • open form with hidden view in autoexec macro
  • tried putting the code in the form wanted, and taken it out again, but not working
 
... please! Just thought I'd push this up to the top again just in case it's been missed.
 
Ally,
Not sure why you need to disable the x on each form if you are using this code as it will not close the form anyway.
Have a look at this example as I can't quite grasp exactly what your problem is with your database this may help.

Steve
 

Attachments

Hi - thanks for replying.

I'm not wanting to do this on every form, (although it may be helpful).

I have code on the particular form in question,

Code:
If IsNull field on a subform AND If IsNull field on another subform Then

MsgBox "You haven't entered information here. Please go back and fill it in etc"

Else

Close etc

I originally tried putting this code on the OnClose event, but it doesn't work - I got the MsgBox up, but it would then carry on closing and I couldn't work out how to Exit the event.

So, alternatively, if I can get this code working, then it doesn't matter so much about the disabling 'X'.
 
Ally,
You would need to do this on the before update action and use the cancel feature to stop the record saving in the first place. That should do it i think.
 
Doing it on BeforeUpdate causes the msgbox to appear every time you try and enter something else in other fields. It's on the second "page" of a form, so there's plenty to enter before you get there.
 
Ally,
The before update event should only fire when the record is saved ?? eg when you manually save it or if you go on to a new record.

Am I mistaken about this?

I have attached a little example for you ... it seems to do what you want.
I have set it up so that field 1 is the required field.

Hope this helps a little.

Steve
 

Attachments

Sorry ... but the test db isn't working for me! It just closes when I click the 'x' with no message and if I try and enter anything, it won't, (as it's read-only I presume).
 
Create a Boolean CanClose field on the Main form, then just toggle the value from the subForm/s.
In the Main form UnloadEvent the code becomes
If CanClose = False Then
Cancel = True
End If
 
Thank you - Can you explain what you mean by "toggle to value to the subforms" please Rich. I asked Col and he wasn't sure either, so that makes me feel a bit better!

Also, do I keep the If IsNull etc code on the unload event too?
 

Users who are viewing this thread

Back
Top Bottom