473,406 Members | 2,208 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Null is making life difficult

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
6 1584

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

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
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
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

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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Bodza Bodza | last post by:
I'm having an argument with an incumbent self-taught programmer that it is OK to use null foreign keys in database design. My take is the whole point of a foreign key is that it's not supposed...
5
by: Nick Keighley | last post by:
Hi, In the beginning the code was:- BRUSHH new_brush = create_brush() BRUSHH old_brush = select_brush (new_brush) draw(...) select_brush (old_brush) destroy_brush (new_brush)
1
by: Shawn B. | last post by:
Greetings, I have have been working for almost 18 months on a set of WebControls where some are similar to the ASP.NET standard and well-enhanced while other controls are completely new and...
64
by: yossi.kreinin | last post by:
Hi! There is a system where 0x0 is a valid address, but 0xffffffff isn't. How can null pointers be treated by a compiler (besides the typical "solution" of still using 0x0 for "null")? -...
351
by: CBFalconer | last post by:
We often find hidden, and totally unnecessary, assumptions being made in code. The following leans heavily on one particular example, which happens to be in C. However similar things can (and...
27
by: David W | last post by:
I'm almost tearing my hair out. A colleague claimed that a null reference can exist, like this: void f( int& p ) { printf( "%d\n", p ); } int main (int argc, char *argv) {
13
by: Karch | last post by:
I find myself doing things like this all the time: if ( SomeObject != null && SomeObject.AnotherObject != null && SomeObject.AnotherObject.YetAnother != null &&...
8
by: Jeff | last post by:
I AM A NEWBIE. ANy help appreciated The following statement crashes when the database entry is dbNUll How do I prevent it Name = ds.Tables(0).Rows.Item(i).ItemArray.GetValue(1)
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.