473,405 Members | 2,344 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,405 software developers and data experts.

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

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 1823
missinglinq
3,532 Expert 2GB
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 Expert 100+
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
Thanks heaps, both solutions worked perfectly.
Cheers,
Jacko7289
Jul 30 '07 #4
missinglinq
3,532 Expert 2GB
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
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...
3
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...
5
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
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...
4
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...
8
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:...
1
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...
6
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...
4
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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...
0
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...
0
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...

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.