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!

Updating field in recordset issues

Status
Not open for further replies.

EddyLLC

Technical User
Mar 15, 2005
304
US
I am trying to put values into a table and having trouble with one specific value. I am using the following code:

Dim dblInvoices As Double
dblInvoices = CDbl(TotInvoice)
strFile = Me.File
Set db = CurrentDb
Set rs = db.OpenRecordset("tbl1", dbOpenDynaset)
rs.FindFirst "File = '" & strFile & "'"
rs.Edit
rs!TotInvoices = dblInvoices
rs.Update
rs.Close

The control, TotInvoice, on the form is unbound but the data I put into it when the form becomes current is is a string for example "3". When I run the code above all the fields are updated (I update more but didn't include those here) except the rs!TotInvoices field. It just changes to its default value of 0 regardless of what I try to put into it.
I just tried commenting out the rs!TotInvoices = dblInvoices and the value was still changed from 1 to its default of 0.

I am lost. Help.
Eddy
 
Take a look at the table in design view - any chance this field somehow got changed to a lookup field? Does it have a default value which would print in the event the CDbl conversion fails?

I have great faith in fools; self-confidence my friends call it.
-Poe
 
It is not a lookup field but it does have a default value of 0, that is a zero. Does that matter? Thanks.
 
If the type conversion fails it matters.
Add a breakpoint here:
dblInvoices = CDbl(TotInvoice)
and then add
debug.print dblInvoices

just to see what you get. Seems like the code would still throw an exception even without an error handler in the code, so this is a REAL long shot....

I have great faith in fools; self-confidence my friends call it.
-Poe
 
Thanks for your help. I ran down the problem. I was resetting the field back to zero in code that ran from a form that was open in the background. My apologizes for wasting your time but thanks for your thoughts.
 
Glad you nailed it - no prob!

I have great faith in fools; self-confidence my friends call it.
-Poe
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top