Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with Code

Status
Not open for further replies.

AndreAraujo

Programmer
Feb 14, 2002
62
PT
Hi,

I having some problems with my aplication, some times i get a error 97, and if i acess the code and go step by step with F8, then get no error, and some times the sub is ignored.
some ideas how to fix this problem????????

Regards, André
 
This is the code where i get the error

Public Function CalculaLinha()
If Me.combo1.Column(5) = "V" Then 'VALOR
x=me.Y
Else
x=me.Y*2
End If
me.k=me.x*1030.33
' 1st error (error 97)
RunCommand acCmdSaveRecord
'2nd "error invalid use of null"
form_projectos.CalculaTotais 'this function is in the main form
End Function


when i press F8 several times the code runs and no error is returned, i verified the values and no Null value is passed to the Function CalculaTotais


 
sorry for being critical but ur code isn't logic.
I think u use it in a for loop or something. To validate a list of values and make the calculations?
Else, maybe u use it in a combo to select a value and make the calculations in a form.
Why docmd.runcommand accmdsaverecord?
what is ur idea with this rule?
why making (unbound, I hope) textboxes for the values?
try Nz(me.x,0)*<values), the Nz function disables Null failures, look at the help files
maybe this function works better
Public Sub CalculaLinha()
var x as double
If Me.combo1.Column(5) = &quot;V&quot; Then 'VALOR
x=nz(me.Y,0)
Else
x= nz(me.Y,0)*2
End If
me.k=nz(x,0)*1030.33
form_projectos.CalculaTotais 'this function is in the main form
End sub
If u don't need y,k (only for the function CalculaTotais) then make also variables. Maybe the null failure is in the CalculaTotais function.
Hope this helps, else u can come back but be informative. So it's not clear to me now what ur idea behind the variabels is, first rule in databases:calculatedvariables never store in tables!!
Gerard
 
Gerad maybe i didnt explain the best way,

The structure of the tables are 1 project as 1 ot more sub projects, the variavel are value of the sub project table.
the idea is to Calculate the total of sub Projects to be stored in the projects table.

The variavel are store in the tabel Sub Projects and the i call the Calculatotais function to calculate the total Sum of sub Projects , the way variavels are calculated depends of the value selected in the combo1, the RunCommand acCmdSaveRecord was inserted because when i call the calculatotais function that opens the table sub Projects that has to contain the values that are being inserted.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top