473,473 Members | 1,963 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Swapping lines of code changes results and error.

15 New Member
I have a form called Main, and a second form called Create.... I open the Create form from a combobox. Then, just click SAVE, which creates a record, and tries to set a text box to the ID for the new record and set the name of the entity of that new record to another text box.

I have many of these. They all work, except one. It is slightly different from the rest. Those two lines of assignments have worked while I was debugging. The first one encountered works. The second one does not work. So at times one of the text boxes has a value and the other is NULL. Both are supposed to have values.

Here is the sub

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmbSaveClose_Click()
  2. Dim x As Integer
  3.  
  4. x = MsgBox("Are you sure you want to save changes?", 4, "Exit?")
  5.  
  6. 'VbNo constant throws back #7
  7. 'VbYes constant throws back #6
  8.  
  9. Me.Txt32 = DLookup("InsuranceCarrierContractID", "ICCDupRecordCheckQ")
  10.  
  11. If x = 7 Then
  12.     Exit Sub
  13.     End If
  14.  
  15. If IsNull(Me.Txt32) Then
  16.     Me.Txt31 = Form_frmMain.Txt65
  17.     DoCmd.RunCommand acCmdSaveRecord
  18.  
  19. ' The preceding code works fine. 
  20. ' Each of the following lines work individually, but only the one executed first works. The other does not appear to execute. I end up with a null in the text box.
  21.  
  22.  
  23.     Forms!frmMain.cboInsuranceCarrierContract = Me.InsuranceCarrierContractID
  24.  
  25.     Forms!frmMain.Txt66 = Me.InsuranceCarrierContractID
  26.  
  27. 'The following code works fine. 
  28.  
  29.     DoCmd.Close
  30.  
  31.     Forms!frmMain!cboInsuranceCarrierContract.RowSource = " SELECT InsuranceCarrierContract.ContractNumber " & _
  32.                                                  " FROM InsuranceCarrierContract " & _
  33.                                                  " ORDER BY InsuranceCarrierContract.ContractNumber;"
  34.  
  35.  
  36.  
  37.     Form_frmMain.cboInsuranceCarrierContract.Locked = False
  38.     Form_frmMain.cboInsuranceCarrierContract.BackColor = Form_frmMain.cboInsuranceCarrier.BackColor
  39.  
  40. Else
  41.     Me.Undo
  42.     DoCmd.Close
  43.  
  44.  
  45. End If
  46. End Sub
Oct 24 '13 #1
1 859
topher23
234 Recognized Expert New Member
Without a LOT more context, I can't make a specific suggestion, but I will make some general observations.

First, ensure that neither Forms!frmMain.cboInsuranceCarrierContract or Forms!frmMain.Txt66 are doing anything that could cause a change to Me.InsuranceCarrierContractID or each other. If everything looks okay there, try changing the periods in the reference to exclamation points. Although Access allows it (and IntelliSense makes it easy to do it), using the period can cause confusions with properties, whereas using an exclamation point (!) tells Access that you're referencing the default collection and not a property.
Oct 28 '13 #2

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

Similar topics

1
by: Chris | last post by:
The strangest thing started happening to me today in Visual Studio .NET 2003. I make changes to my code and compile it, but none of my changes are in the compiled program. The compiled program...
0
by: Lars Grøtteland | last post by:
Hello! This is an IDE question, and I can't find one IDE newsgroup. How can I enable the Apply Code Changes(alt+F10)? I tried to get into Tools-Debugging-Edit and Continue, but I'm not shure...
0
by: Lars Grøtteland | last post by:
Hello! In VC6.0 there was an option - Apply Code Changes(Alt+F10) when something changed in the code during debug. I can't find it in .NET 2003? Where is it? Has it been taken away? If this...
2
by: Lothar Behrens | last post by:
Hi, this is an unusual question here, but I think, it is C++ related due to the fact that my code is written with it. I have written an ODBC wrapper that - if checked out with my last working...
6
by: zoltix | last post by:
Hi, I would like to access to execute specific commands but the privileges are not enough from an aspx Page. Because this service run as IU_IISSERVER, therefore aspx hasn’t access to these...
1
by: Reason | last post by:
Hi, Does anyone know how to run a find that excludes source lines that are totally comments? (I have used regex with good results for some other purposes, but not this one.) Stephen B.
2
by: chandu | last post by:
Hello, if create a new project is visual studio 2005 C# windows application. If i run the application First time VS allows me to debug the code. if i made any changes to code and debug again it...
1
by: shamlafazal | last post by:
When i use Send Form Results to a Database and an E-mail Address and Use the File Upload Component Simultaneously , am getting an error mentioned below. Please any can help me on this. "Database...
0
by: mbewers1 | last post by:
Hi there I have a strange situation in which I have made some code changes to a VisualStudio project and, when I build it and run it in Internet Explorer, the changes are shown but, when I run it...
1
by: denvermuseka | last post by:
If Trim(Text4) = "" Then clsbooks.SearchBooksFrm lstBooks, "" Else clsbooks.SearchBooksFrm lstBooks, Text4.Text End If 'the code produces an error written: Run-time error 424
0
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...
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...
1
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...
1
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...
0
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.