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

VB Close command creating roecords

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.GoToRecord , , 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_Company-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 2005
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
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)...
2
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...
35
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...
4
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
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...
4
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...
4
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...
3
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,...
5
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...
1
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: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
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
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.