473,659 Members | 3,420 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1589

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_mi sc = Nz(Me.the_compa ny, "")
.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
42401
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 to be optional, it's very definition is it's a necessary link to the parent table and part of the definition. If it's optional it shouldn't be part of the definition of a table and should be in a linking table instead. Comments?
5
1214
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
1666
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 interesting. All my controls are implemented from scratch (in VB.NET). Some are C#, er I plan to have a second copy. I'm more productive in VB.NET (mainly because of the better intellisense support -- yes, I rely on it because I don't remember...
64
3899
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")? - AFAIK C allows "null pointers" to be represented differently then "all bits 0". Is this correct? - AFAIK I can't `#define NULL 0x10000' since `void* p=0;' should work just like `void* p=NULL'. Is this correct?
351
12953
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 do) occur in any language. These assumptions are generally made because of familiarity with the language. As a non-code example, consider the idea that the faulty code is written by blackguards bent on foulling the language. The term...
27
4207
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
2497
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 && SomeObject.AnotherObject.YetAnother.HelpMePlease != null) { // Do Something }
8
3089
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
8428
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8851
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8748
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8531
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8628
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7359
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5650
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
1978
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1739
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.