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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

run time error for recordset update

Status
Not open for further replies.
Jul 30, 2007
42
US
I added a check box to the access form and to the table (“fed_express” with data type = yes/no) . I am getting an error message if I don’t check off the fed_express box. The error message is "run time error 3421: data type conversion error". I tried to debug but and found out it stopped at rs.fields (“fed_express”). During the debug, I noticed that “rs.fields(“fed_express”).value appeared to be “False” when I placed my cursor at the “rs.fields(“fed_express”) and [Forms]![custinfo]!fed_express is equal to “”. I was able to enter the first customer information without check off the fed_express box. However, I am getting error message when I tried to enter the 2nd customer information. The form clears out all the value for each fields after I click on the print button. I really don’t know how I can fix this. Any help will be greatly appreciated.

Thanks

Set rs = db_curr.OpenRecordset("Select * From tblcust")
rs.AddNew
rs.Fields("custid").Value = [Forms]![custinfo]!custID
rs.Fields("fed_express").Value = [Forms]![custinfo]!fed_express
rs.Fields("tracking").Value = [Forms]![custinfo]!tracking
rs.Update
rs.Close
Set rs = Nothing


Private Sub Print_Click()

Custid.value = ""
tracking.Value = ""
fed_express.Value = ""

stopsub:

End Sub
 
This may help:

Code:
rs.Fields("fed_express").Value = Nz([Forms]![custinfo]!fed_express, False)



 
Thanks for the tip. I tried again and still doesn't work. Any ideas?? It look like the application is thinking the fed_express field is a required field. Any ideas how to fix this?? Any help will be greatly appreciated.

thanks
 
data type = yes/no

Should I change the fed_express.value = false instead set to ""??

thanks

Private Sub Print_Click()

Custid.value = ""
tracking.Value = ""
fed_express.Value =
 
Yes, I do. I also think that you should use the notes that JoeAtWork has provided.
 
I did tried the notes that Joeatwork has provided but I am still getting the same error message and have no clue how to fix this. Any help will be greatly appreciated.

thanks
 
I made a form with a single unbound checkbox on it, and then tried all the different values it could be. It's either going to be:
1. Null
2. -1 (True)
3. 0 (False)

The only way this should not be working for you is either:
1. rs.Fields("fed_express") is not a boolean field
2. You have not translated my code correctly (are you by any chance putting quotes around False?

Can you try my code again, and paste it into your next post?

 
Thanks for your help. I copied the whole thing to my code and it kept error out. I think the reason that was not workin because I set fed_express.value = "" and I don't think "" is a valid value. It worked when I change to fed_express.value = null under the print_click(). I am not sure if this is the correct way to fix the code. Can you please tell me if I am doing the right thing? Any help will be greatly appreciated.

Private Sub Print_Click()

fed_express.Value = ""

CHANGED TO

fed_express.value = null
 
In your post dated 10 Sep 07 18:49 you suggested setting fed_express.Value to False. In my response, I said that I thought it was a good idea. I still think it's a good idea.
 
ituser2008 said:
I copied the whole thing to my code and it kept error out
1. You still haven't posted the code that implements my solution. I can't just take it for granted that you implemented it correctly. I need to see what you've done.
2. "kept error out" is not useful information. Error number? Error description?

As I said before, the valid values for an unbound checkbox are:
Null
True
False
-1
0

Anything else will likely give you an error.

 
I am so sorry. I thought I have posted the error message at my original post. Here is the error message. I think i know where i did wrong. You code worked but because I have set fed_express.value = "" instead of null for clear out the field, maybe that was the reason i am getting an error message. Thanks for your help. Private Sub Print_Click()

fed_express.Value = ""

The error message is "run time error 3421: data type conversion error".
 
You did state your original error in your first post. But after you made changes, and you still get an error, I can't assume that you are getting the same error. Therefore after each change you need to say what the error is (or at least say it's the same as the original error).

But I think you have found the source of the problem in any case.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top