473,320 Members | 1,946 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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

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
5 2171
jforbes
1,107 Expert 1GB
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
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, 688 views)
Jan 17 '17 #3
jforbes
1,107 Expert 1GB
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
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
Can anyone reply me a code thats work? plz.
Feb 6 '17 #6

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

Similar topics

5
by: Ellen Manning | last post by:
Using A2K. I need the syntax to set the recordsource for a subform within a subform. The "main" subform's recordsource changes based on user input. I need to change the recordsource on the...
2
by: Mark B | last post by:
I have a form with a subform (normal) that itself has a subform (datasheet). I can't get a delete command button to work with the following code. It says "delete not available now". Any...
2
by: Michael | last post by:
Hi, I have a form (switchboard like form) thats loaded into a MDI parent form. This form is the start off point for all the other screens in the app. I have placed a exit button on the switchboard...
3
by: rdemyan via AccessMonster.com | last post by:
I need help with code to close two forms at the same time, FormA and FormB. I need code that can be used from either form and needs to work with both a 'Close' button on each form as well as if the...
6
by: Ryan | last post by:
My application has a main form from which the user can use the Menu to open other forms. Each form opens in a separate window while the main form remains open all the time. Is their any code I...
3
by: Ronald S. Cook | last post by:
I know how to close and open a form... Well.. but can you tell me how can I do this..... Example... There are 2 forms...named formA and formB and each of them have their own button named...
1
by: =?Utf-8?B?WmlnZ3lTaG9ydA==?= | last post by:
Using a Button control, I tried to reset its colour ("color" to those of you on the other side of the pond). I tried to use the BackColor attribute - but that is in System.Windows.Forms.Button....
1
by: Jstyle | last post by:
Ok I know how to make the X ask before the form closes in VB.NET. However, I am trying to make a control where a button asks 'are you sure you want to close' before it closes the form. This is what...
7
by: jgoodnight | last post by:
Hello, I've read through many forum posts on this issue today but can't seem to find a solution that fits my particular case. I have three main tables: - tblIssues (PK: IssueID) -...
1
by: Crombam | last post by:
Hi to all, After searching the net for a couple of hours I just have to ask the question. How can I close a report with a subform (Pivot Chart) when this Pivot Chart is having no data? ...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.