473,388 Members | 1,390 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,388 software developers and data experts.

Auto closing

18
Can I make my form close automaticlly after I choose a command button from it
Feb 7 '08 #1
10 1657
NeoPa
32,556 Expert Mod 16PB
Add the following code to the end of you Command Button procedure :
Expand|Select|Wrap|Line Numbers
  1. Call DoCmd.Close(ObjectType:=acForm, ObjectName:=Me.Name)
Feb 7 '08 #2
tawjaw
18
Add the following code to the end of you Command Button procedure :
Expand|Select|Wrap|Line Numbers
  1. Call DoCmd.Close(ObjectType:=acForm, ObjectName:=Me.Name)
This is my command button name: que_Click
were should I replace it in the code
thx for helping
Feb 7 '08 #3
mshmyob
904 Expert 512MB
Are you running a MACRO or CODE?
This is my command button name: que_Click
were should I replace it in the code
thx for helping
Feb 7 '08 #4
tawjaw
18
Are you running a MACRO or CODE?
I am running a Code
I'm making a quiz maker using Access
I'm putting in switchboard (Open Quiz) so a form will open to ask if I want ANSWERS or QUESTIONS (the report will open)
I want after pressing one of these buttons to close the form automatically (which ask ANS or Que)
Feb 7 '08 #5
MindBender77
234 100+
I am running a Code
I'm making a quiz maker using Access
I'm putting in switchboard (Open Quiz) so a form will open to ask if I want ANSWERS or QUESTIONS (the report will open)
I want after pressing one of these buttons to close the form automatically (which ask ANS or Que)
Could you not just put this code into the OnOpen event of the report?
Expand|Select|Wrap|Line Numbers
  1. DoCmd.Close acForm, "FormName",acSaveNo
  2.  
Feb 7 '08 #6
NeoPa
32,556 Expert Mod 16PB
This is my command button name: que_Click
were should I replace it in the code
thx for helping
Post in the code you currently have for your que_Click Command Button, then I can tell you where to put the extra line. Essentially it's as you said - at the end.

If you post it though I can show you exactly where. Please remember to use the [ CODE ] tags provided of course.
Feb 7 '08 #7
tawjaw
18
Post in the code you currently have for your que_Click Command Button, then I can tell you where to put the extra line. Essentially it's as you said - at the end.

If you post it though I can show you exactly where. Please remember to use the [ CODE ] tags provided of course.
The code for que_Click is
Expand|Select|Wrap|Line Numbers
  1.  Private Sub que_Click()
  2. On Error GoTo Err_que_Click
  3.  
  4.     Dim stDocName As String
  5.  
  6.     stDocName = "Questions"
  7.     DoCmd.OpenReport stDocName, acPreview
  8.  
  9. Exit_que_Click:
  10.     Exit Sub
  11.  
  12. Err_que_Click:
  13.     MsgBox Err.Description
  14.     Resume Exit_que_Click
  15.  
  16. End Sub 
The form name is: Quiz
Feb 8 '08 #8
NeoPa
32,556 Expert Mod 16PB
You need it after line #7 then :
Expand|Select|Wrap|Line Numbers
  1. Private Sub que_Click()
  2. On Error GoTo Err_que_Click
  3.  
  4.     Dim stDocName As String
  5.  
  6.     stDocName = "Questions"
  7.     DoCmd.OpenReport stDocName, acPreview
  8.     Call DoCmd.Close(ObjectType:=acForm, ObjectName:=Me.Name)
  9.  
  10. Exit_que_Click:
  11.     Exit Sub
  12.  
  13. Err_que_Click:
  14.     MsgBox Err.Description
  15.     Resume Exit_que_Click
  16.  
  17. End Sub 
It would need to be in a similar place for the other Command Button too.
Feb 8 '08 #9
tawjaw
18
You need it after line #7 then :
Expand|Select|Wrap|Line Numbers
  1. Private Sub que_Click()
  2. On Error GoTo Err_que_Click
  3.  
  4.     Dim stDocName As String
  5.  
  6.     stDocName = "Questions"
  7.     DoCmd.OpenReport stDocName, acPreview
  8.     Call DoCmd.Close(ObjectType:=acForm, ObjectName:=Me.Name)
  9.  
  10. Exit_que_Click:
  11.     Exit Sub
  12.  
  13. Err_que_Click:
  14.     MsgBox Err.Description
  15.     Resume Exit_que_Click
  16.  
  17. End Sub 
It would need to be in a similar place for the other Command Button too.
Thanks a lot it worked.
I'm still new with Access and I never learned Visual Basic language
However I'm still 14
Feb 9 '08 #10
NeoPa
32,556 Expert Mod 16PB
14's a good age to be learning all this stuff :)

I'm glad that helped.
Feb 9 '08 #11

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

Similar topics

2
by: janet | last post by:
HI, I had a question on auto-commit in DB2 EEE V8 on AIX V5. Here is my example.. there are two script A.sh , B.SQL A.sh is following:
3
by: Chris Youlden | last post by:
Is there a way to auto quit a database (Acc2000) after a predetermined period of inactivity? In other words if a user does not use the database for, say, 5 minutes could this be recognised and auto...
6
by: Fabian Härle | last post by:
Hi, if I write to a tet file via a System.IO.TextWriter the changes to the file are not done before I close the file. Is there a possibility to always save the file with every change? The point...
6
by: Al the programmer | last post by:
I want to catch the Closing event for my form. I created a test windows app using the wizard. I then create the Closing event by clicking the lightning bolt on the properties pane. The code is...
1
by: **Developer** | last post by:
When I get a closing event in a MID Child form I don't know if the child form is closing or the main form is closing. Is there a way to tell? Thank
4
by: Alex Nitulescu | last post by:
Hi. Is there any way to really disable that stupid HTML auto-formatting in VS.NET ? I have a page with a lot of complicated HTML (many complex tables etc) and JScripts. If it's not formatted...
10
by: Charles Law | last post by:
For some reason, when I click the X to close my MDI parent form, the action appears to be re-directed to one of the MDI child forms, and the parent remains open. I am then unable to close the...
4
by: Academic | last post by:
Does it make sense to put this If e.Cancel Then Exit Sub at the beginning of form closing events so if the user cancels the app's exiting in one Closing routine he will not be asked again by...
1
by: Paul Rubin | last post by:
it looks like contextlib.closing fails to be idempotent, i.e. wrapping closing() around another closing() doesn't work. This is annoying because the idea of closing() is to let you use legacy...
1
by: =?Utf-8?B?QVZM?= | last post by:
How to autorefresh parent window after closing child window?.. I've used window.opener.location = window.opener.location; But it's not working..how to do it???
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.