473,698 Members | 2,841 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

VB Close command creating roecords

6 New Member
I have a form and it is to creat a 'link' between a project and a company. Creating a record form this table will simply create a record in a databse with the company ID and project ID. Project ID is selected form a drop down bax and Company ID is selected from a combo box. I am trying to create a script that if you click exit form, and one or the other, or both of the fields have a selection it will bring up message box and inform the user of the situation, and what will happen. That i am not having trouble with. I am having trouble with the Docmd.close! it seems that this command creates a new record, even when the
DoCmd.GoToRecor d , , acNewRec command is not there. The form is set as a data entry form. I have included my if statements but i dont think the problem is there. I have taken out the close commands and records are not created, i put them back in and the form closes and creates the record. How do i close the form without it creating the record.

P.S. i have also tried doCmd.close as upposed to coCmd.close acForm, "form_Compa ny-Project" with the same record creating result.

Any help would be greatly appreciated

Cheers,

Oxford Consult

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command22_Click()
  2.  
  3. If Me.Combo25.Value = 0 Then
  4.     If Me.Combo8.Value = 0 Then
  5.         DoCmd.Close acForm, "Form_Company-Project"
  6.         DoCmd.OpenForm "Form_Mainpage"
  7.     Else
  8.         MsgBox "You have only selected a company and no link will be created", vbCritical, "Note"
  9.         DoCmd.Close
  10.         DoCmd.OpenForm "Form_Mainpage"
  11.     End If
  12. Else
  13.     If Me.Combo8.Value = 0 Then
  14.         MsgBox "You have only selected a project and no link will be created", vbCritical, "Note"
  15.         DoCmd.Close acForm, "Form_Company-Project"
  16.         DoCmd.OpenForm "Form_Mainpage"
  17.     Else
  18.         zmessage = MsgBox("You have slected a company and project to create a link but have not created a link." & vbCrLf _
  19.         & "Do you wish to do so now?", vbYesNo + vbQuestion, "Link selected but not created")
  20.         If zmessage = 6 Then
  21.             MsgBox ""
  22.             MsgBox "A link has been created", vbInformation, "Note"
  23.             DoCmd.Close acForm, "Form_Company-Project"
  24.             DoCmd.OpenForm "Form_Mainpage"
  25.         Else
  26.             DoCmd.Close acForm, "Form_Company-Project"
  27.             DoCmd.OpenForm "Form_Mainpage"
  28.         End If
  29.     End If
  30. End If
  31.  
  32. End Sub
  33.  
Jun 21 '07 #1
1 2018
OxfordConsult
6 New Member
I have figured it out. I found another forum with this same problem and tried some of thier remedys. There final solution was to use :

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdExit_Click()
  2.     Call DoCmd.Close(ObjectType:=acForm, ObjectName:=Me.Name)
  3. End Sub
  4.  
however this did not work for me, and I kept getting the same error. In the end i tried the undo function that didnt work for them but did for me. Might have somehitng to do with the messageboxes and keeping them on focus.

Expand|Select|Wrap|Line Numbers
  1. Call Me.Undo
  2. DoCmd.Close
  3.  
Hope this helps anyone else with a simlar probelm.

Cheers,

Oxford
Jun 21 '07 #2

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

Similar topics

4
47517
by: Bill | last post by:
I need help closing a CMD window when it is executed from Access. 1) The batch file is called from Access. 2) Access closes, 3) the batch runs a copy of the access database (creating a backup) 4) Once the copy is complete, the batch file opens the Access database again 5) EXIT should close out the cmd window but it does not execute that line
2
9016
by: Guy Babbitt | last post by:
I have an MDI application that starts an instance of a child form at application start. I have an event handler on a combo box checking for the selected value to change. When the select value changes, I call a method on the parent form to change some menu options, and then I need to close the child form. My code looks something like this: private void ddlDatabase_SelectedIndexChanged(object sender, System.EventArgs e) {...
35
11403
by: Eric Sabine | last post by:
In my Finally block, I was using cn.close (where cn is an ADO.NET connection object, SQLConnection to be exact) and then I came across the following in some microsoft code. If Not cn Is Nothing Then CType(cn, IDisposable).Dispose() End If I have to admit, I'm not sure what happens here. Will someone explain this line of code (the middle one, not the if statement LOL) to me please?
4
6730
by: rs | last post by:
how I the client tell the server that the socket is closed? or this there an even that informs the server that the clients socket is close? Oh, I am using vb.net 2003 Thanks
0
3905
by: bonita | last post by:
In my ASP.NET page, I have 2 checkboxes for users to choose which crystal report they want to display. These two reports use different tables. If report1 has been choosen and displayed in the crystal report, then I cannot check another checkbox to display report2 afterwards. If I close the website and open again, I can choose report2 and display as crystal report correct, but now I cannot check the checkbox1 to display report 1 afterwards....
4
4995
by: Bit byte | last post by:
I have a project that I normally build (without problems) from the DevStudio IDE. However, I have embarked on automating all my builds (this test project being one of several). The project creates a DLL. I am able to build the project without any probs in the IDE, however - when I build the project from the command line (using the same options shown in the 'Command line' node in the 'Project Settings' dialog box), I get the following...
4
3705
by: RICHARD BROMBERG | last post by:
I am writing a small application using Access 2000 and I am using a Switchboard. The last item in the switchboard is to be used to close the application.. I selected Exit Application from the dropdown list of functions and it does close the application, but it leaves Access open. What I want to do is exit the application and close Access. I can do this (exit the application and close Access) by using a command
3
18708
by: creative1 | last post by:
Here is how you create a complex data report that involves parent and child commands and you can update information at runtime. Its pretty straight forward to work with simple queries; however, working with complex reports is tricky Assumption: Reader of this article have basic knowledge of creating data reports. Creating a Parent-Child Command and create a DataReport Suppose we have a database called company with two tables ...
5
5889
by: Tony | last post by:
I am continuing to develop an Access 2007 application which was originally converted from Access 2003. In Access 2003 I was able to disable the Access Close button in the top righthand corner of the screen. I have been unable to find any way to disable this button in Access 2007 and subsequently I have been forced to find ways to detect and handle the situations after the Access Close button has been clicked. I have been largely...
0
8683
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9031
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
8901
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
8871
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
7739
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...
0
4622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2336
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.