By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,827 Members | 2,220 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,827 IT Pros & Developers. It's quick & easy.

button i subform who close only the subform and not all forms

P: 14
I have a mainform called STV_Feilsak and a subform called PCSak. I use Access 2013. and vba access.

I have tried to make a button who close the subform, but close all forms. need to close only subform.

I have tried diffrent code, but all fails. CLOSE button code are in PCSak form.

How to solve this?

Whats wrong? I tried different codes, but it fails. None of these are right or not in right place. examples under.

Expand|Select|Wrap|Line Numbers
  1. Me.Parent.PCSak.Visible = False
Expand|Select|Wrap|Line Numbers
  1. Me![PCSak].Visible = False
Expand|Select|Wrap|Line Numbers
  1. Me.Parent.STV_Feilsak.SetFocus
  2. Me.Parent.PCSak.Visible = False
Expand|Select|Wrap|Line Numbers
  1. Forms!Form_STV_Feilsak.ControlOnMainForm.SetFocus
  2. Forms!PCSak.SubformControlName.Visible = False
Expand|Select|Wrap|Line Numbers
  1. Me![STV_Feilsak].SetFocus
Expand|Select|Wrap|Line Numbers
  1. Me![STV_Feilsak]!SetFocus
  2. Me.Visible = False
Jan 11 '17 #1
Share this Question
Share on Google+
5 Replies


jforbes
Expert 100+
P: 1,107
I'm not sure what you are attempting to do. I'm guessing you are attempting to click a Button and Hide a SubForm.

Setting any Control's Visible or Enabled property to False while the Control has Focus tends to cause an error. If you want to set a SubForm's visibility to False, you should do it from the MainForm so that the SubForm doesn't have Focus.

If you were to create a Button on the MainForm and put something like this in the OnClick event, it will Toggle the Visibility of the Form:
Expand|Select|Wrap|Line Numbers
  1. Me.PCSak.Visible = Not Me.PCSak.Visible
Jan 16 '17 #2

P: 14
Hello, what i am trying to do is : I have a mainform and a subform who looks lika a popup when it shows up. In the Subform i have a button named CLOSE. How to make it works? Its easy if i use a button i mainform, but i want it to work in subform.

In the picure you can see what i mean. The button who says "Lukke skjema" Means close subform. And if i make it work, then it close both forms. So only subform to close i want.

Attached Images
File Type: png IMG_0157.JPG_256x256.png (86.2 KB, 186 views)
Jan 17 '17 #3

jforbes
Expert 100+
P: 1,107
You can use the Wizard to create a Close Button for your SubForm. If you were to do so, you would get some code like this for your button:
Expand|Select|Wrap|Line Numbers
  1. If Me.Dirty Then Me.Dirty = False
  2. DoCmd.Close
Jan 17 '17 #4

P: 14
Hello!
I dont know how to use me.dirty code. How should the code be??
I tried wizard, but it use macro, not vba. And when i use macro it close both forms. My problem are still the same. How to close only one form.
Jan 19 '17 #5

P: 14
Can anyone reply me a code thats work? plz.
Feb 6 '17 #6

Post your reply

Sign in to post your reply or Sign up for a free account.