By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,962 Members | 1,776 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,962 IT Pros & Developers. It's quick & easy.

Null is making life difficult

P: n/a
Done a lot of forum checking, tried several possibilities.
Still not getting it to work.
Please show me my error!

form has several combo boxes storing an integer or nothing (were not
activated depending on another combo box)

want to save to table "joborder" several numeric fields (long integer)

keep getting error 3421 "data type conversion error"

tried variants of Nz, tried if isnull, tried everything I found here.

just want it to skip the field if the field on the form is empty.

If I comment out the empty numeric fields it runs great, except for the
missing data (duh)

please tell me what I doing wrong, I know it is something simple, but
I am now lost.
here are a couple of tries:

With rs_joborder
.AddNew
rs_joborder![cust_misc] = Nz(Me![the_company])
rs_joborder![jobnr_retro] = Me.retro_jobnr

Oct 25 '06 #1
Share this Question
Share on Google+
6 Replies


P: n/a

stevenrec wrote:
Done a lot of forum checking, tried several possibilities.
Still not getting it to work.
Please show me my error!

form has several combo boxes storing an integer or nothing (were not
activated depending on another combo box)

want to save to table "joborder" several numeric fields (long integer)

keep getting error 3421 "data type conversion error"

tried variants of Nz, tried if isnull, tried everything I found here.

just want it to skip the field if the field on the form is empty.

If I comment out the empty numeric fields it runs great, except for the
missing data (duh)

please tell me what I doing wrong, I know it is something simple, but
I am now lost.
here are a couple of tries:

With rs_joborder
.AddNew
rs_joborder![cust_misc] = Nz(Me![the_company])
rs_joborder![jobnr_retro] = Me.retro_jobnr
What happens if you do this:

With rs_joborder
.AddNew
If Not IsNull(Nz(Me![the_company]) Then
rs_joborder![cust_misc] = Me![the_company]
If Not IsNull(Me.retro_jobnr) Then
rs_joborder![jobnr_retro] = Me.retro_jobnr

Bruce

Oct 25 '06 #2

P: n/a

stevenrec wrote:
Done a lot of forum checking, tried several possibilities.
Still not getting it to work.
Please show me my error!

form has several combo boxes storing an integer or nothing (were not
activated depending on another combo box)

want to save to table "joborder" several numeric fields (long integer)

keep getting error 3421 "data type conversion error"

tried variants of Nz, tried if isnull, tried everything I found here.

just want it to skip the field if the field on the form is empty.

If I comment out the empty numeric fields it runs great, except for the
missing data (duh)

please tell me what I doing wrong, I know it is something simple, but
I am now lost.
here are a couple of tries:

With rs_joborder
.AddNew
rs_joborder![cust_misc] = Nz(Me![the_company])
rs_joborder![jobnr_retro] = Me.retro_jobnr
What happens if you do this:

With rs_joborder
.AddNew
If Not IsNull(Me![the_company]) Then
rs_joborder![cust_misc] = Me![the_company]
If Not IsNull(Me.retro_jobnr) Then
rs_joborder![jobnr_retro] = Me.retro_jobnr

Bruce

Oct 25 '06 #3

P: n/a
stevenrec wrote:
>
With rs_joborder
.AddNew
rs_joborder![cust_misc] = Nz(Me![the_company])
You're repeating rs_joborder within a with/end with. I've encountered
trouble with that before.

This is the format I use - I specify what the null value is.

With rs_joborder
.AddNew
.fields!cust_misc = Nz(Me.the_company, "")
.update
end with

Never fails for me.

--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Be Careful, Big Bird!" - Ditto "TIM-MAY!!" - Me
Oct 25 '06 #4

P: n/a
Thanks for the help guys,

I have tried both options, and used your ideas in other ways.
Still getting the data conversion error.

The fields are returning ""
but the table is still trying to update null.

tried defining each as different varaiables, filling it, then running
the .addnew, no luck.

if I can get to my ftp server from work, I will post a link to a .doc
file

I am going to try some differennt ways around it.

steven

Oct 26 '06 #5

P: n/a

stevenrec wrote:
Thanks for the help guys,

I have tried both options, and used your ideas in other ways.
Still getting the data conversion error.

The fields are returning ""
but the table is still trying to update null.

tried defining each as different varaiables, filling it, then running
the .addnew, no luck.

if I can get to my ftp server from work, I will post a link to a .doc
file

I am going to try some differennt ways around it.
A data conversion error should be fairly simple to diagnose. First I
would set a breakpoint at the .AddNew statement and step through the
code to see what value is actually being used to set each field, i.e.
whether it is a Null, an empty string, or perhaps a zero. Then make
sure that your field definition in the underlying table allows you to
save what you're trying to save (for example, you'd want to be sure
that if you're trying to save an empty string, the underlying field
definition in your table must be text and must have have 'allow zero
length' set to yes. If you're saving a Null you'll want to be sure
that the field is not required). make sure that all your field
definitions are the way you want them to be and then modify your code
appropriately.

Bruce

Oct 26 '06 #6

P: n/a
found the problem, where is the dunce hat?

the form has a combo box to select the type of work order. the after
update selects different fields to enable or disable.
since the user can enter info, then change the type of work order, I
had on afterupdate set it to empty all the fields so nothing would be
saved later that did not apply.
I emptied the fields using = ""
no matter how I tried later to save the information it was suppying ""
instead of null. which of course led to the error.
changed the afterupdate to set all the values to null and it works just
like I expected it to.
But the worst part is how long it took me to find this.

when the error lies at the top of the code, no matter how much effort
is done, the bottom of the code will fail.

thanks everyone for the help

Oct 27 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.