Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ms access form with just close x 1

Status
Not open for further replies.

patriciaxxx

Programmer
Jan 30, 2012
277
GB
These are the form settings:
Close Button = Yes
ControlBox = Yes
BorderStyle = Dialog
MaxMinBitton = None

The above setting gives me the Close button (X) but also the form ControlBox.

If I change the settings to:

Close Button = Yes
ControlBox = No
BorderStyle = Dialog
MaxMinBitton = None

Both the Close button (X) and the form ControlBox, infact all buttons, are removed.
I would like to display the close button (X) only and none of the forms other buttons / controls.

Does anyone know how this could be achieved, maybe using API and the forms handle or something?
 
The technique I posted will work in any version of Access. However, can only be used unbounded.
 
Hello MajP

Is that an Access form or a UserForm?

If it’s an Access form which settings do I apply?

Also, can you tell what I might be doing wrong with the code I posted just above your reply?
 
>which I used to manipulate the window buttons and system menu, I’ve found it

Yes, but that just disables the Close 'button' (which, depending on OS and theme, may or may not gray it as well), which is an easy effect - but not what you stated you wanted to do. And you can certainly do exactly the same thing for an Access form. Not quite sure why it isn't working for you. Although I'd point out that if your form is not a popup it does not have a system menu, so the code can't disable Close
 
Hello strongm

Yes, the popup property sorted it.

I was just curious about the code working as I remembered it.

Your solution was perfect for my needs and again I thank you for the time and effort you put in to helping me.
 
Hello strongm

Oh dear!

Just tried your wonderful code and today it won’t work, very strange.

Just keep getting the following runtime error.

automation error
The object invoked has disconnected from its clients

?
 
That is a userform, but would work for unbounded.
 
>automation error
>The object invoked has disconnected from its clients

Have you modified the code at all? This is an error Access raises if it encounters a VB error of some description in the message loop code. As I said, it isn't really production quality code - on factor of that being that there is no error trapping (and error trapping is tricky for VBA in message loops anyway)
 
Hello strongm

No, I haven’t changed anything.

The only thing I can say is that yesterday when it worked it was on a friends PC and today it’s on mine.

My friends PC is Windows XP pro which I installed and mine is the same.

One thing which may make a difference. I don’t know, is that my friends PC is Access 2003 and mine is 2002.

But I’ve just rebuilt your example in a new Access container exactly like I did yesterday, but still it doesn’t work just gives that same error.

Is that it? end of the line?


 
Noyt quite yet ...

Go to the VBA IDE, and select Debug/Compile <database> and see if you get any errors
 
I did compile the code without any errors.

I also tried decompiling the code using the /decompile switch and then compile the code again also without any errors.

Just doesn’t want to work with my Access.


 
Comment out this line:

hWndDlg = CreateDialogIndirectParam(0, d.dlgtemp, hwnd, AddressOf DlgFunc, 0)

and try running again. What happens?
 
Did as you said…

But get the same error.

When the runtime error presents itself, if I click debug it goes to the UserForm1.Show and highlights it in yellow.

If I click end the dialog closes and the database is frozen but form2 has opened with the caption and close button (not when I comment out the line of course) but when I click my command button on that form or the close X to close the form then Access crashes.

This was the same behavior I was getting yesterday just thought I’d mention it incase it gave you any pointers as to what’s wrong.
 
> it goes to the UserForm1.Show

What UserForm1.Show? My code had no such thing ...
 
Ah

When you said add a VBA UserForm…

I created UserForm1

When you said run the userform…

I need to programmatically run the userform so used .show

I’ve just tried the code running the userform using the run menu “run sub/userform F5” and I get vb error message 0 same thing?


 
Now I am confused. If you go with a UserForm, then you do not need any code. I showed that already.
 
Hello MajP

> Now I am confused. If you go with a UserForm, then you do not need any code. I showed that already.

I know that a UserForm presents in this way but I was specifically looking for an Access form solution.

strongm has provided such a solution if we can get it to work.

But thank you for your help.
 
majp, the userform is simply being used as a launch pad for the purposes of the example. It isn't part of the solution at all.

>vb error message 0

Error message 0. Really?

Also, did you put some controls on the Access Form? I'm wondering if one of them might be having an issue with having the parent window changed (it is, after all, a bit of a hack)

 
I put 2 text box and 2 command buttons all of which I just removed and tried it without any controls but still get the same thing.

Given the example as it is I have to click the button on the userform to run it and the userform stays open freezing everything which is no good.

If the userform isn’t part of the solution can I run the code from a macro or from a command button on another Access form and without the UserForm ever showing.
 
Hello strongm

Well, I took the code from the userform and placed it behind a button on an Access form but when I run it I get the same thing. You did say the code is “likely to explode Access” and that what happens, everything freezes then Access crashes.

Any last ideas on what can be done to make the code work?


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top