473,725 Members | 2,193 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to create a button which closes the current form and then opens a new form

10 New Member
Hi,
I've got a form (SearchForm1) which searches the student number using the surname, given name, date of birth. Once the student number is shown i want the user to click a button which will close the search form (SearchForm1) and then open the survey form (SurveyForm1).
In short i want a button which closes the current form (permanently) and opens another form at the same time.
Any suggetions is very much appreciated.
Cheers,
Jacko7289
Jul 30 '07 #1
4 1837
missinglinq
3,532 Recognized Expert Specialist
This will do it. Create a button; when the Wizard comes up, hit Cancel. Now go into Properties - Events and click to the right of the OnClick Property. Click on the ellipsis (...).Click on Code Builder and enter this code:
Expand|Select|Wrap|Line Numbers
  1. Private Sub YourCommandButton_Click()
  2. On Error GoTo Err_YourCommandButton_Click
  3.  
  4.     DoCmd.OpenForm "FormToOpen"
  5.     DoCmd.Close acForm, "FormToClose"
  6.  
  7. Exit_YourCommandButton_Click:
  8.     Exit Sub
  9.  
  10. Err_YourCommandButton_Click:
  11.     MsgBox Err.Description
  12.     Resume Exit_YourCommandButton_Click
  13.  
  14. End Sub
Welcome to TheScripts

Linq ;0)>
Jul 30 '07 #2
damonreid
114 Recognized Expert New Member
Just make a new button that opens the new form using the critera you require using the button wizzard.

Then go into the VB for that button.

Add

Expand|Select|Wrap|Line Numbers
  1. DoCmd.Close
in the line before the open command is called.
Jul 30 '07 #3
Jacko7289
10 New Member
Thanks heaps, both solutions worked perfectly.
Cheers,
Jacko7289
Jul 30 '07 #4
missinglinq
3,532 Recognized Expert Specialist
Glad we could help!

Linq ;0)>
Jul 30 '07 #5

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

Similar topics

1
2541
by: Tom Cusick | last post by:
We have a Job Shop database. When I get an order in I put all the line item information into the database. Some orders have multiple lines and most of the information is the same. (eg. Customer Name, PO, Due Date, Received, etc.) 2 questions: 1. I have a button to create a new record on my switchboard, but what I would like that button to do is create a new record but enter in the next job number. Our job numbers are 'H1001', so I...
3
1980
by: needin4mation | last post by:
Hi, I have an asp:button that has a ShowModalDialog script attribute added to it. When the ShowModalDialog opens the user is supposed to select some data which is then sent back to the calling .aspx page and that data sent back is placed in a hidden textbox for processing when the form posts back from the asp:button (the same button that called the ShowModalDialog windows, calls the window and then postsback). This works fine.
5
5431
by: Wonder | last post by:
How can I create or use the msgobx to show a message without a default button. The user has explicity to click on the button, so the msgbox closes it. Thanks,
10
3306
by: jerry.ranch | last post by:
I have a series of comboboxes on a form that are used to display forms in DS view (theres a qry behind it all). This is working well for me. Some people like to see the data in DS view, some in normal form view. I know they have the option to change that, but I trying to make this as user friendly as possible (and to learn about VBA for myself) So I thought I'd use two option buttons to identify this choice ........one for Forms view,...
4
9576
by: ghadley_00 | last post by:
Hi, Can anyone recommend a piece of VBA code I could attach to a button in a MS Form form that will close the current form and bring the switchboard to foreground. I'm trying to integrate a form of buttons into the way the switchboard gets used. Best wishes, George Hadley
8
20364
by: barb | last post by:
So that the world at large benefits from our efforts, here is one fully documented way to use Windows Irfanview freeware to create thumbnail web galleries (http://www.irfanview.com). STEP 1: Start with original thumbnails & two empty sub directories STEP 2: Create smaller versions of the originals for one sub directory STEP 3: Create thumbnail version of the originals the other sub directory STEP 4: Create an index.html pointing to the...
1
2200
by: zack | last post by:
I am really struggling to get to grips with this issue, would grateful for any advice. I have a form 'Applicant_Person' with various student contact data. There is a combo box to 2 options of either 'Enquiry' or 'Application'. If 'Enquiry' is chosen then cmd button 'Interviews' needs to be disabled. If 'Application' is chosen then cmb button 'Interviews needs to be enabled.
6
2905
by: martin DH | last post by:
**Urgent Need** I'll throw out the basics and any assistance is very, very, very much appreciated! Access 2003 on XP On a form (frmMain) is an option group of check boxes (ReportFrame) from which a user can choose a specific report to generate. The user selects the report of choice then presses a comand button (CmdRunRpt). The command button runs using the code below: Private Sub CmdRunRpt_Click() If ReportFrame = 1 Then...
4
21467
by: Luke Bailey | last post by:
I'm trying to complete some changes to a database that I have created and I need to finish it by tomorrow morning! Here's the situation: I have a form where people can order a number of products. They can set this form to varying statuses so that their supervisors can review the orders before they get placed. When the user (call them technicians) sets the order form to "review" status, the code goes through each individual item that...
0
8752
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9401
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9257
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9176
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9113
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8097
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6702
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6011
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4784
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.