473,789 Members | 2,773 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Run-Time Error

I have a button on my (continuous) form which when pressed performs
the foll 2 actions:

1) it resets the field "Init_Bal" to 0
2) it computes the closing balances & stores them in the field
"Init_Bal"

Now ... the 1st time I run "Cmd_Compute_Cl ick", the program works
perfectly. However, If I run "Cmd_Compute_Cl ick" again immediately, I
get the foll error:

Run-time error '-2147352567 (800200009)':
The data has been changed

Access then highlighs the foll (last) line:
Me.Txt_Init_Bal = Nz(ClBal_Final)
Below are my 2 subs ... hope somebody can throw more light on this.
Private Sub Cmd_Compute_Cli ck()
Dim rs As Object
Set rs = Me.Recordset
rs.MoveFirst

'**** Performing Validations here
*************** *************** ************
If IsNull(Me.Txt_Y earEndDate) Then
MsgBox "YEAR-ENDING DATE cannot be left BLANK !", vbOKOnly +
vbExclamation, "Error !"
Me.Txt_YearEndD ate.SetFocus
Exit Sub
End If

'************** *************** *************** *************** *************** ***

DoCmd.RunSQL "UPDATE DPATMST SET Init_Bal = 0;"
Me.Refresh 'Otherwise if we stop execution here, the Init-Bal
column still reflects the OLD values

rs.MoveFirst
Do Until rs.EOF
Call Compute_Totals
rs.MoveNext
Loop
rs.MoveFirst
rs.Requery
Me.Requery

MsgBox "Closing Balances Computed !", vbOKOnly + vbInformation,
"Message"
End Sub
Private Sub Compute_Totals( )
Dim OPBAL_Final As Double, DrAndCr As Double, ClBal_Final As
Double

' ***** Op.Bal from Master-File ... DPATMST *****
OPBAL_Final = Nz(Me.OPBAL)

'===== LEDGERBAL i.e. DEBITS+CREDITS fm DPATDAT ... Calculation
DSUM Way =========
DrAndCr = Nz(DSum("nz([DEBIT])-nz([CREDIT])", "DPATDAT", "[code] =
" & Me.CODE & " AND [Inv_Date] < " & DMY(Txt_YearEnd Date)))

'===== CLOSING BAL Calculation ===============
ClBal_Final = Nz(OPBAL_Final) + Nz(DrAndCr)

' ***** Storing Closing Balances *****
Me.Txt_Init_Bal = Nz(ClBal_Final)

End Sub

Jul 30 '07 #1
5 2585
The funny part is that once I click on either "End" or
"Debug" (buttons provided by the error msg) & then again run
"Cmd_Compute_Cl ick", it works fine.

Best Rgds,
Prakash.


prakashwadhw... @gmail.com wrote:
I have a button on my (continuous) form which when pressed performs
the foll 2 actions:

1) it resets the field "Init_Bal" to 0
2) it computes the closing balances & stores them in the field
"Init_Bal"

Now ... the 1st time I run "Cmd_Compute_Cl ick", the program works
perfectly. However, If I run "Cmd_Compute_Cl ick" again immediately, I
get the foll error:

Run-time error '-2147352567 (800200009)':
The data has been changed

Access then highlighs the foll (last) line:
Me.Txt_Init_Bal = Nz(ClBal_Final)
Below are my 2 subs ... hope somebody can throw more light on this.
Private Sub Cmd_Compute_Cli ck()
Dim rs As Object
Set rs = Me.Recordset
rs.MoveFirst

'**** Performing Validations here
*************** *************** ************
If IsNull(Me.Txt_Y earEndDate) Then
MsgBox "YEAR-ENDING DATE cannot be left BLANK !", vbOKOnly +
vbExclamation, "Error !"
Me.Txt_YearEndD ate.SetFocus
Exit Sub
End If

'************** *************** *************** *************** *************** ***

DoCmd.RunSQL "UPDATE DPATMST SET Init_Bal = 0;"
Me.Refresh 'Otherwise if we stop execution here, the Init-Bal
column still reflects the OLD values

rs.MoveFirst
Do Until rs.EOF
Call Compute_Totals
rs.MoveNext
Loop
rs.MoveFirst
rs.Requery
Me.Requery

MsgBox "Closing Balances Computed !", vbOKOnly + vbInformation,
"Message"
End Sub
Private Sub Compute_Totals( )
Dim OPBAL_Final As Double, DrAndCr As Double, ClBal_Final As
Double

' ***** Op.Bal from Master-File ... DPATMST *****
OPBAL_Final = Nz(Me.OPBAL)

'===== LEDGERBAL i.e. DEBITS+CREDITS fm DPATDAT ... Calculation
DSUM Way =========
DrAndCr = Nz(DSum("nz([DEBIT])-nz([CREDIT])", "DPATDAT", "[code] =
" & Me.CODE & " AND [Inv_Date] < " & DMY(Txt_YearEnd Date)))

'===== CLOSING BAL Calculation ===============
ClBal_Final = Nz(OPBAL_Final) + Nz(DrAndCr)

' ***** Storing Closing Balances *****
Me.Txt_Init_Bal = Nz(ClBal_Final)

End Sub
Jul 30 '07 #2
On Mon, 30 Jul 2007 03:51:42 -0700, pr************* @gmail.com wrote:
>I have a button on my (continuous) form which when pressed performs
the foll 2 actions:
Is your form Bound? If so, are the UPDATE statements running agains the SAME table/datasource as the Form? If that's
true, then you need to perform the updates on the form ... in other words, instead of using RunSQL, just set the value
directly on the form:

DoCmd.RunSQL "UPDATE DPATMST SET Init_Bal = 0;"

becomes

Me.SomeTextFiel d = 0

Generally, with Bound forms, you should do all calculations on the form (i.e. use Me.SomeField + Me.SomeOtherfie ld, and
not UPDATE statements, etc) and NOT rely on recordsets/sql statements - assuming, that is, that you're manipulating the
same data. If your ComputeTotals function takes values from your form and uses values from other tables, then that's
perfectly fine (and that's what it appears to do).

>
1) it resets the field "Init_Bal" to 0
2) it computes the closing balances & stores them in the field
"Init_Bal"

Now ... the 1st time I run "Cmd_Compute_Cl ick", the program works
perfectly. However, If I run "Cmd_Compute_Cl ick" again immediately, I
get the foll error:

Run-time error '-2147352567 (800200009)':
The data has been changed

Access then highlighs the foll (last) line:
Me.Txt_Init_Ba l = Nz(ClBal_Final)
Below are my 2 subs ... hope somebody can throw more light on this.
Private Sub Cmd_Compute_Cli ck()
Dim rs As Object
Set rs = Me.Recordset
rs.MoveFirst

'**** Performing Validations here
************** *************** *************
If IsNull(Me.Txt_Y earEndDate) Then
MsgBox "YEAR-ENDING DATE cannot be left BLANK !", vbOKOnly +
vbExclamatio n, "Error !"
Me.Txt_YearEndD ate.SetFocus
Exit Sub
End If

'************* *************** *************** *************** *************** ****

DoCmd.RunSQL "UPDATE DPATMST SET Init_Bal = 0;"
Me.Refresh 'Otherwise if we stop execution here, the Init-Bal
column still reflects the OLD values

rs.MoveFirst
Do Until rs.EOF
Call Compute_Totals
rs.MoveNext
Loop
rs.MoveFirst
rs.Requery
Me.Requery

MsgBox "Closing Balances Computed !", vbOKOnly + vbInformation,
"Message"
End Sub
Private Sub Compute_Totals( )
Dim OPBAL_Final As Double, DrAndCr As Double, ClBal_Final As
Double

' ***** Op.Bal from Master-File ... DPATMST *****
OPBAL_Final = Nz(Me.OPBAL)

'===== LEDGERBAL i.e. DEBITS+CREDITS fm DPATDAT ... Calculation
DSUM Way =========
DrAndCr = Nz(DSum("nz([DEBIT])-nz([CREDIT])", "DPATDAT", "[code] =
" & Me.CODE & " AND [Inv_Date] < " & DMY(Txt_YearEnd Date)))

'===== CLOSING BAL Calculation ===============
ClBal_Final = Nz(OPBAL_Final) + Nz(DrAndCr)

' ***** Storing Closing Balances *****
Me.Txt_Init_Bal = Nz(ClBal_Final)

End Sub
Scott McDaniel
scott@takemeout _infotrakker.co m
www.infotrakker .com
Jul 30 '07 #3
Thanks Scott for such a prompt answer.

However, your suggestion: Me.SomeTextFiel d = 0 will work only for
the current row
& not for all the rows in the table
as I am doing with: DoCmd.RunSQL "UPDATE DPATMST SET Init_Bal = 0;"

Please excuse my ignorance & would greatly appreciate any further
ideas / tips / pointers.

Best Rgds,
Prakash.


On Jul 30, 3:28 pm, Scott McDaniel <scott@NoSpam_I nfotrakker.com>
wrote:
On Mon, 30 Jul 2007 03:51:42 -0700, prakashwadhw... @gmail.com wrote:
I have a button on my (continuous) form which when pressed performs
the foll 2 actions:

Is your form Bound? If so, are the UPDATE statements running agains the SAME table/datasource as the Form? If that's
true, then you need to perform the updates on the form ... in other words, instead of using RunSQL, just set the value
directly on the form:

DoCmd.RunSQL "UPDATE DPATMST SET Init_Bal = 0;"

becomes

Me.SomeTextFiel d = 0

Generally, with Bound forms, you should do all calculations on the form (i.e. use Me.SomeField + Me.SomeOtherfie ld, and
not UPDATE statements, etc) and NOT rely on recordsets/sql statements - assuming, that is, that you're manipulating the
same data. If your ComputeTotals function takes values from your form and uses values from other tables, then that's
perfectly fine (and that's what it appears to do).


1) it resets the field "Init_Bal" to 0
2) it computes the closing balances & stores them in the field
"Init_Bal"
Now ... the 1st time I run "Cmd_Compute_Cl ick", the program works
perfectly. However, If I run "Cmd_Compute_Cl ick" again immediately, I
get the foll error:
Run-time error '-2147352567 (800200009)':
The data has been changed
Access then highlighs the foll (last) line:
Me.Txt_Init_Bal = Nz(ClBal_Final)
Below are my 2 subs ... hope somebody can throw more light on this.
Private Sub Cmd_Compute_Cli ck()
Dim rs As Object
Set rs = Me.Recordset
rs.MoveFirst
'**** Performing Validations here
*************** *************** ************
If IsNull(Me.Txt_Y earEndDate) Then
MsgBox "YEAR-ENDING DATE cannot be left BLANK !", vbOKOnly +
vbExclamation, "Error !"
Me.Txt_YearEndD ate.SetFocus
Exit Sub
End If
'************** *************** *************** *************** *************** ***
DoCmd.RunSQL "UPDATE DPATMST SET Init_Bal = 0;"
Me.Refresh 'Otherwise if we stop execution here, the Init-Bal
column still reflects the OLD values
rs.MoveFirst
Do Until rs.EOF
Call Compute_Totals
rs.MoveNext
Loop
rs.MoveFirst
rs.Requery
Me.Requery
MsgBox "Closing Balances Computed !", vbOKOnly + vbInformation,
"Message"
End Sub
Private Sub Compute_Totals( )
Dim OPBAL_Final As Double, DrAndCr As Double, ClBal_Final As
Double
' ***** Op.Bal from Master-File ... DPATMST *****
OPBAL_Final = Nz(Me.OPBAL)
'===== LEDGERBAL i.e. DEBITS+CREDITS fm DPATDAT ... Calculation
DSUM Way =========
DrAndCr = Nz(DSum("nz([DEBIT])-nz([CREDIT])", "DPATDAT", "[code] =
" & Me.CODE & " AND [Inv_Date] < " & DMY(Txt_YearEnd Date)))
'===== CLOSING BAL Calculation ===============
ClBal_Final = Nz(OPBAL_Final) + Nz(DrAndCr)
' ***** Storing Closing Balances *****
Me.Txt_Init_Bal = Nz(ClBal_Final)
End Sub

Scott McDaniel
scott@takemeout _infotrakker.co mwww.infotrakke r.com

Jul 30 '07 #4
I'm sorry Scott ... I forgot to answer your question.

Yes !! The form is bound ! So once again ... how do I UPDATE [ALL
ROWS] of the the INIT_BAL field without a RunSQL command ??

Thx again & Hope someone can point me in the right direction.

Rgds,
Prakash.


On Jul 30, 3:28 pm, Scott McDaniel <scott@NoSpam_I nfotrakker.com>
wrote:
On Mon, 30 Jul 2007 03:51:42 -0700, prakashwadhw... @gmail.com wrote:
I have a button on my (continuous) form which when pressed performs
the foll 2 actions:

Is your form Bound? If so, are the UPDATE statements running agains the SAME table/datasource as the Form? If that's
true, then you need to perform the updates on the form ... in other words, instead of using RunSQL, just set the value
directly on the form:

DoCmd.RunSQL "UPDATE DPATMST SET Init_Bal = 0;"

becomes

Me.SomeTextFiel d = 0

Generally, with Bound forms, you should do all calculations on the form (i.e. use Me.SomeField + Me.SomeOtherfie ld, and
not UPDATE statements, etc) and NOT rely on recordsets/sql statements - assuming, that is, that you're manipulating the
same data. If your ComputeTotals function takes values from your form and uses values from other tables, then that's
perfectly fine (and that's what it appears to do).


1) it resets the field "Init_Bal" to 0
2) it computes the closing balances & stores them in the field
"Init_Bal"
Now ... the 1st time I run "Cmd_Compute_Cl ick", the program works
perfectly. However, If I run "Cmd_Compute_Cl ick" again immediately, I
get the foll error:
Run-time error '-2147352567 (800200009)':
The data has been changed
Access then highlighs the foll (last) line:
Me.Txt_Init_Bal = Nz(ClBal_Final)
Below are my 2 subs ... hope somebody can throw more light on this.
Private Sub Cmd_Compute_Cli ck()
Dim rs As Object
Set rs = Me.Recordset
rs.MoveFirst
'**** Performing Validations here
*************** *************** ************
If IsNull(Me.Txt_Y earEndDate) Then
MsgBox "YEAR-ENDING DATE cannot be left BLANK !", vbOKOnly +
vbExclamation, "Error !"
Me.Txt_YearEndD ate.SetFocus
Exit Sub
End If
'************** *************** *************** *************** *************** ***
DoCmd.RunSQL "UPDATE DPATMST SET Init_Bal = 0;"
Me.Refresh 'Otherwise if we stop execution here, the Init-Bal
column still reflects the OLD values
rs.MoveFirst
Do Until rs.EOF
Call Compute_Totals
rs.MoveNext
Loop
rs.MoveFirst
rs.Requery
Me.Requery
MsgBox "Closing Balances Computed !", vbOKOnly + vbInformation,
"Message"
End Sub
Private Sub Compute_Totals( )
Dim OPBAL_Final As Double, DrAndCr As Double, ClBal_Final As
Double
' ***** Op.Bal from Master-File ... DPATMST *****
OPBAL_Final = Nz(Me.OPBAL)
'===== LEDGERBAL i.e. DEBITS+CREDITS fm DPATDAT ... Calculation
DSUM Way =========
DrAndCr = Nz(DSum("nz([DEBIT])-nz([CREDIT])", "DPATDAT", "[code] =
" & Me.CODE & " AND [Inv_Date] < " & DMY(Txt_YearEnd Date)))
'===== CLOSING BAL Calculation ===============
ClBal_Final = Nz(OPBAL_Final) + Nz(DrAndCr)
' ***** Storing Closing Balances *****
Me.Txt_Init_Bal = Nz(ClBal_Final)
End Sub

Scott McDaniel
scott@takemeout _infotrakker.co mwww.infotrakke r.com

Jul 30 '07 #5
Got it at last !! After the UPDATE statement, I changed the
Me.Refresh to Me.Requery & it now works perfectly !!

I presume it puts the recordset back in sync.

Thx to all who helped. (I was really getting a bit desperate - had to
submit tomm to a client).

Best Rgds,
Prakash.

On Jul 30, 2:51 pm, prakashwadhw... @gmail.com wrote:
I have a button on my (continuous) form which when pressed performs
the foll 2 actions:

1) it resets the field "Init_Bal" to 0
2) it computes the closing balances & stores them in the field
"Init_Bal"

Now ... the 1st time I run "Cmd_Compute_Cl ick", the program works
perfectly. However, If I run "Cmd_Compute_Cl ick" again immediately, I
get the foll error:

Run-time error '-2147352567 (800200009)':
The data has been changed

Access then highlighs the foll (last) line:
Me.Txt_Init_Bal = Nz(ClBal_Final)

Below are my 2 subs ... hope somebody can throw more light on this.

Private Sub Cmd_Compute_Cli ck()
Dim rs As Object
Set rs = Me.Recordset
rs.MoveFirst

'**** Performing Validations here
*************** *************** ************
If IsNull(Me.Txt_Y earEndDate) Then
MsgBox "YEAR-ENDING DATE cannot be left BLANK !", vbOKOnly +
vbExclamation, "Error !"
Me.Txt_YearEndD ate.SetFocus
Exit Sub
End If

'************** *************** *************** *************** *************** ***

DoCmd.RunSQL "UPDATE DPATMST SET Init_Bal = 0;"
Me.Refresh 'Otherwise if we stop execution here, the Init-Bal
column still reflects the OLD values

rs.MoveFirst
Do Until rs.EOF
Call Compute_Totals
rs.MoveNext
Loop
rs.MoveFirst
rs.Requery
Me.Requery

MsgBox "Closing Balances Computed !", vbOKOnly + vbInformation,
"Message"
End Sub

Private Sub Compute_Totals( )
Dim OPBAL_Final As Double, DrAndCr As Double, ClBal_Final As
Double

' ***** Op.Bal from Master-File ... DPATMST *****
OPBAL_Final = Nz(Me.OPBAL)

'===== LEDGERBAL i.e. DEBITS+CREDITS fm DPATDAT ... Calculation
DSUM Way =========
DrAndCr = Nz(DSum("nz([DEBIT])-nz([CREDIT])", "DPATDAT", "[code] =
" & Me.CODE & " AND [Inv_Date] < " & DMY(Txt_YearEnd Date)))

'===== CLOSING BAL Calculation ===============
ClBal_Final = Nz(OPBAL_Final) + Nz(DrAndCr)

' ***** Storing Closing Balances *****
Me.Txt_Init_Bal = Nz(ClBal_Final)

End Sub

Jul 31 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
4932
by: leroybt.rm | last post by:
Can someone tell me how to run a script from a interactive shell I type the following: >>>python filename >>>python filename.py >>>run filename >>>run filename.py >>>/run filename >>>/run filename.py
4
3217
by: Ed | last post by:
Hello, I took a course in asp about 2 years ago and I was practicing with IIS 5.0. Then I put it down for a while. Now trying to get back to it. I can't run asp files from subdirectories of my root directory, but I can run asp files from the root directory of my website and I can run htm files from the subdirectories. If I run localhost/mytest.asp
6
20087
by: orekin | last post by:
Hi There I have been trying to come to grips with Application.Run(), Application.Exit() and the Message Pump and I would really appreciate some feedback on the following questions .. There are quite a few words in this post but the questions are actually quite similar and should be fairly quick to answer ... (1) What is Happening with the Threads
13
5097
by: Bob Day | last post by:
Using vs2003, vb.net I start a thread, giving it a name before start. Code snippet: 'give each thread a unique name (for later identification) Trunk_Thread.Name = "Trunk_0_Thread" ' allow only 1 thread per line Trunk_Thread.ApartmentState = ApartmentState.STA
19
2227
by: Bryan | last post by:
How can i run a bit of code straight from the IDE? Right now i make a temporary button and put the code behind that, then i run debug mode and click on the button. Is there a way to highlight some code and tell it to run that? Is there a "scratchpad" type window like in VBA where I can write some simple code to be executed? Thanks for the help in advance
9
4691
by: Brett Wesoloski | last post by:
I am new to VS2005. I changed my program.cs file to be a different form I am working on. But when I go to run the application it still brings up the form that was originally declared as new. When I put in a break point the program does not stop. It is in debug mode. If I change the program.cs file back to the form that was originally being used. The program does go into debug mode. But if I change code in that file it isn't using...
7
2949
by: Lee Crabtree | last post by:
I remember when I was first getting into .NET Forms programming that there was a rather emphatic rule about not constructing a form before calling Application.Run with it. So this: Application.Run(new Form1()); was okay, but this: Form1 form = new Form1();
8
3023
by: David Thielen | last post by:
Hi; In our setup program how do I determine if I need to run "aspnet_regiis –i" and if so, is there an API I can calll rather than finding that program on the user's disk and calling it? -- thanks - dave david_at_windward_dot_net http://www.windwardreports.com
3
11303
by: traceable1 | last post by:
Is there a way I can set up a SQL script to run when the instance starts up? SQL Server 2005 SP2 thanks!
7
11747
by: mxdevit | last post by:
Task: run application from ASP.NET for example, you have a button on ASP.NET page, when press this button - one application is invoked. the code to run application (for example, notepad) is (on C#) System.Diagnostics.Process.Start("notepad");
0
10412
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
10200
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...
0
9986
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...
1
7529
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
6769
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
5422
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4093
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
3703
muto222
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.