473,789 Members | 2,408 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem testing fieldvalue in form data-entry = yes

Hi,

TBL_CONTACT_PER SON
CNTP_ID (auto)
CNTP_LAST_NAME (required = yes)
CNTP_FUNCTION (required = no)
CNTP_..... (all required = no)

FRM_CONTACT_PER SON_ADD_NEW
Property DATA ENTRY = YES

No closebutton ( user leaves pressing 'Add' or 'Exit no adding'
CmdAdd
CmdExitNoAdd

Problem with Private Sub CmdAdd_Click() > see code below *********

If the user presses 'add' i want to test if Me.CNTP_LAST_NA ME has data. If
not > MsgBox "Unable to add person without LastName!" and stay in the form.

1. if i do not enter any value in any field the test
IsNull(Me.CNTP_ LAST_NAME) returns True
but MsgBox Me.CNTP_LAST_NA ME triggers error 'invalid use of null" ???

2. if i only enter the CNTP_FUNCTION leaving Me.CNTP_LAST_NA ME blanc, the
test IsNull(Me.CNTP_ LAST_NAME) returns False
Please help,

Filip

*************** *************** *************** *************** *************** *
**********
Private Sub CmdAdd_Click()

On Error GoTo ErrHandling

If IsNull(Me.CNTP_ LAST_NAME) Then
MsgBox Me.CNTP_LAST_NA ME 'this msgbox is just for testing
MsgBox "Unable to add person, need LastName!"
Exit Sub
Else
DoCmd.Close acForm, Me.Name, acSaveYes
End If

Exit Sub

ErrHandling:
MsgBox Err.Number & " " & Err.Description
End Sub

*************** *************** *************** *******
Nov 12 '05 #1
7 2153
Filips Benoit wrote:
Hi,

TBL_CONTACT_PER SON
CNTP_ID (auto)
CNTP_LAST_NAME (required = yes)
CNTP_FUNCTION (required = no)
CNTP_..... (all required = no)

FRM_CONTACT_PER SON_ADD_NEW
Property DATA ENTRY = YES

No closebutton ( user leaves pressing 'Add' or 'Exit no adding'
CmdAdd
CmdExitNoAdd

Problem with Private Sub CmdAdd_Click() > see code below *********

If the user presses 'add' i want to test if Me.CNTP_LAST_NA ME has data. If
not > MsgBox "Unable to add person without LastName!" and stay in the form.

1. if i do not enter any value in any field the test
IsNull(Me.CNTP_ LAST_NAME) returns True
but MsgBox Me.CNTP_LAST_NA ME triggers error 'invalid use of null" ???

2. if i only enter the CNTP_FUNCTION leaving Me.CNTP_LAST_NA ME blanc, the
test IsNull(Me.CNTP_ LAST_NAME) returns False
Please help,

Filip

*************** *************** *************** *************** *************** *
**********
Private Sub CmdAdd_Click()

On Error GoTo ErrHandling

If IsNull(Me.CNTP_ LAST_NAME) Then
MsgBox Me.CNTP_LAST_NA ME 'this msgbox is just for testing
MsgBox "Unable to add person, need LastName!"
Exit Sub
Else
DoCmd.Close acForm, Me.Name, acSaveYes
End If

Exit Sub

ErrHandling:
MsgBox Err.Number & " " & Err.Description
End Sub

*************** *************** *************** *******


Yes, the MsgBox function requires a string expression as the prompt,
hence the error when you send null to it.

Why Me.CNTP_LAST_NA ME would not yield a null if left blank is a bit of a
mystery, but one thing I'd suggest is to use the notation
Me!CNTP_LAST_NA ME or Me("CNTP_LAST_N AME") as matter of course as the dot
should be for properties and methods, not memebers of collections. This
may not be the cause of the problem here but may cause problems elsewhere.

Set a breakpoint where your test fails and use the imeediate window to
test the field's value, e.g.

?CNTP_LAST_NAME
?Isnull(CNTP_LA ST_NAME)
?Len(CNTP_LAST_ NAME)
?CNTP_LAST_NAME =""

See what transpires, there may be some other code or something else
setting the field to a zero length string, which isn't null but you
can't tell the difference by looking at it on the screen, both null and
zero length string will look just blank.

Nov 12 '05 #2
Two things:

1) Make sure that the table.field TBL_CONTACT_PER SON.CNTP_LAST_N AME does not
allow zero-length strings.

2) A MsgBox call cannot "parse" a null value....since your test IF ISNULL(
CNTP_LAST_NAME) returns TRUE, there's no point in trying to force MsgBox to
parse its "null-ness." Just use MsgBox "The Last Name field must be provided."
Nov 12 '05 #3

Comments mixed in below...

Mike Storr
www.veraccess.com

Filips Benoit wrote:

1. if i do not enter any value in any field the test
IsNull(Me.CNTP_ LAST_NAME) returns True
but MsgBox Me.CNTP_LAST_NA ME triggers error 'invalid use of null" ???
If you think about it, you are testing to see if there is no value, and
if that is true, you are trying to display no value in a msgbox. You
simply can't do that. Change your use of MsgBox to display something
that will never be NULL.

2. if i only enter the CNTP_FUNCTION leaving Me.CNTP_LAST_NA ME blanc, the
test IsNull(Me.CNTP_ LAST_NAME) returns False

What does MsgBox display in this case? It may indicate that you have set
a DefaultValue, or made it an empty string somehow.

Please help,

Filip

*************** *************** *************** *************** *************** *
**********
Private Sub CmdAdd_Click()

On Error GoTo ErrHandling

If IsNull(Me.CNTP_ LAST_NAME) Then
MsgBox Me.CNTP_LAST_NA ME 'this msgbox is just for testing
MsgBox "Unable to add person, need LastName!"
Exit Sub
Else
DoCmd.Close acForm, Me.Name, acSaveYes
End If

Exit Sub

ErrHandling:
MsgBox Err.Number & " " & Err.Description
End Sub

*************** *************** *************** *******

Nov 12 '05 #4
Hi,

TBL_CONTACT_PER SON is in a SQL-server-DB
and CNTP_LAST_NAME property 'Allow null' = false

This works:

If IsNull(Me.CNTP_ LAST_NAME) Or Me.CNTP_LAST_NA ME = vbNullString Then

It seems that when the record is totaly blanc, the value of CNTP_LAST_NAME =
null
and when i add any value in any other field CNTP_LAST_NAME becomes = ""
Why

Filip
"Trevor Best" <nospam@localho st> wrote in message
news:40******** *************** @auth.uk.news.e asynet.net...
Filips Benoit wrote:
Hi,

TBL_CONTACT_PER SON
CNTP_ID (auto)
CNTP_LAST_NAME (required = yes)
CNTP_FUNCTION (required = no)
CNTP_..... (all required = no)

FRM_CONTACT_PER SON_ADD_NEW
Property DATA ENTRY = YES

No closebutton ( user leaves pressing 'Add' or 'Exit no adding'
CmdAdd
CmdExitNoAdd

Problem with Private Sub CmdAdd_Click() > see code below *********

If the user presses 'add' i want to test if Me.CNTP_LAST_NA ME has data. If not > MsgBox "Unable to add person without LastName!" and stay in the form.
1. if i do not enter any value in any field the test
IsNull(Me.CNTP_ LAST_NAME) returns True
but MsgBox Me.CNTP_LAST_NA ME triggers error 'invalid use of null" ???

2. if i only enter the CNTP_FUNCTION leaving Me.CNTP_LAST_NA ME blanc, the test IsNull(Me.CNTP_ LAST_NAME) returns False
Please help,

Filip

*************** *************** *************** *************** *************** * **********
Private Sub CmdAdd_Click()

On Error GoTo ErrHandling

If IsNull(Me.CNTP_ LAST_NAME) Then
MsgBox Me.CNTP_LAST_NA ME 'this msgbox is just for testing
MsgBox "Unable to add person, need LastName!"
Exit Sub
Else
DoCmd.Close acForm, Me.Name, acSaveYes
End If

Exit Sub

ErrHandling:
MsgBox Err.Number & " " & Err.Description
End Sub

*************** *************** *************** *******


Yes, the MsgBox function requires a string expression as the prompt,
hence the error when you send null to it.

Why Me.CNTP_LAST_NA ME would not yield a null if left blank is a bit of a
mystery, but one thing I'd suggest is to use the notation
Me!CNTP_LAST_NA ME or Me("CNTP_LAST_N AME") as matter of course as the dot
should be for properties and methods, not memebers of collections. This
may not be the cause of the problem here but may cause problems elsewhere.

Set a breakpoint where your test fails and use the imeediate window to
test the field's value, e.g.

?CNTP_LAST_NAME
?Isnull(CNTP_LA ST_NAME)
?Len(CNTP_LAST_ NAME)
?CNTP_LAST_NAME =""

See what transpires, there may be some other code or something else
setting the field to a zero length string, which isn't null but you
can't tell the difference by looking at it on the screen, both null and
zero length string will look just blank.

Nov 12 '05 #5
Hi,

TBL_CONTACT_PER SON is in a SQL-server-DB
and CNTP_LAST_NAME property 'Allow null' = false

This works:

If IsNull(Me.CNTP_ LAST_NAME) Or Me.CNTP_LAST_NA ME = vbNullString Then

It seems that when the record is totaly blanc, the value of CNTP_LAST_NAME =
null
and when i add any value in any other field CNTP_LAST_NAME becomes = ""
Why

Filip

"DCM Fan" <dc****@aol.com SPNOAM> wrote in message
news:20******** *************** ****@mb-m28.aol.com...
Two things:

1) Make sure that the table.field TBL_CONTACT_PER SON.CNTP_LAST_N AME does not allow zero-length strings.

2) A MsgBox call cannot "parse" a null value....since your test IF ISNULL(
CNTP_LAST_NAME) returns TRUE, there's no point in trying to force MsgBox to parse its "null-ness." Just use MsgBox "The Last Name field must be

provided."
Nov 12 '05 #6
Hi,

TBL_CONTACT_PER SON is in a SQL-server-DB
and CNTP_LAST_NAME property 'Allow null' = false

This works:

If IsNull(Me.CNTP_ LAST_NAME) Or Me.CNTP_LAST_NA ME = vbNullString Then

It seems that when the record is totaly blanc, the value of CNTP_LAST_NAME =
null
and when i add any value in any other field CNTP_LAST_NAME becomes = ""
Why

Filip

"Mike Storr" <no****@noname. con> wrote in message
news:Jv******** *******@news20. bellglobal.com. ..

Comments mixed in below...

Mike Storr
www.veraccess.com

Filips Benoit wrote:

1. if i do not enter any value in any field the test
IsNull(Me.CNTP_ LAST_NAME) returns True
but MsgBox Me.CNTP_LAST_NA ME triggers error 'invalid use of null" ???


If you think about it, you are testing to see if there is no value, and
if that is true, you are trying to display no value in a msgbox. You
simply can't do that. Change your use of MsgBox to display something
that will never be NULL.

2. if i only enter the CNTP_FUNCTION leaving Me.CNTP_LAST_NA ME blanc, the test IsNull(Me.CNTP_ LAST_NAME) returns False


What does MsgBox display in this case? It may indicate that you have set
a DefaultValue, or made it an empty string somehow.

Please help,

Filip

*************** *************** *************** *************** *************** * **********
Private Sub CmdAdd_Click()

On Error GoTo ErrHandling

If IsNull(Me.CNTP_ LAST_NAME) Then
MsgBox Me.CNTP_LAST_NA ME 'this msgbox is just for testing
MsgBox "Unable to add person, need LastName!"
Exit Sub
Else
DoCmd.Close acForm, Me.Name, acSaveYes
End If

Exit Sub

ErrHandling:
MsgBox Err.Number & " " & Err.Description
End Sub

*************** *************** *************** *******

Nov 12 '05 #7
<<and when i add any value in any other field CNTP_LAST_NAME becomes = ""
Why>>

That's the million-dollar question, and only the application developer can
answer it. SQL Server does NOT insert zero-length strings on its own.

So, either the form has "" as its default value, or some stored-procedure
somwhere has '' (two apostrophes) for an INSERT statement, or something....SQ L
Server does not enter zero-length strins on its own (well, SQL 7 + anyway...I'm
not sure about SQL 6.5)
Nov 12 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
3695
by: Dave Blair | last post by:
Hi, I have a problem with our intranet, we are planning to install Firefox instead of Internet Explorer onto some new PCs. However, we can't get the following JavaScript to work in Firefox and similar code is used in lots of the intranet stuff. The code should bring up a message box with a warning and not allow the user to continue unless they have filled in the entry in an html form (the form is called 'myauthor').
3
1649
by: Marc Llenas | last post by:
Hi there, I'm stuck on a validation function for a form and I cannot figure out what the problem is. The page is in ASP. Any ideas? The function being called is: <script language="JavaScript" type="text/javascript"> function checkform ( form ) {
1
1011
by: Karen | last post by:
Hi, I'm just working on my first ASP.net site, and I'm having some problems. In standard ASP I can easily display output based on whether any content exists for the database field I'm displaying, but I can't seem to work out how to do the same thing in ASP.net. What I'm trying to do is display the content of a Dataset if it doesn't match a particular value. I have a NavName Dataset, which contains the name of the section of the site...
7
1781
by: Trickynick1001 | last post by:
Hi, a newbie here. I don't have a real firm grasp on the idea of Javascript, as I'm used to programming in Qbasic and C. I'm not used to OOP. Anyway, I really don't have any idea what the problem is with this code, it just simply won't work properly. Some of the functions aren't done, but the main one gives me a Not a Number message in the text box where the calculations are supposed to come up. I tried to use a parseInt on my stuff,...
0
1184
by: Paul | last post by:
Hi All. We have a custom class which we serialize. This class is regularly updated, and the old requests do not have a problem opening, apart from a couple!!! When it try's to deserialize the class I receive "One of the serialized keys is null". I tried to change the constructor "below" to check if the object is null to change is to a new object and set the value but still have the same error. Any ideas? as we need to keep backward...
2
2065
by: Brave | last post by:
I'm hoping someone can help me with a small issue. I have an asp page that displays informaton from an Access database. I want to create a form that allows users to display only data that matches their search criteria. I have made many forms like this in Front Page with the Database results wizard, but I want to manually code it. Here is the code I use to display the data from a database.
7
2516
by: Girish Kanakagiri | last post by:
Hi, Can any one please resolve this compilation error it is very urgent. ..\DBAccess\Localization.cpp(381) : error C2593: 'operator + ' is ambiguous Error executing cl.exe DK_SSE_VCT.dll - 1 error(s), 0 warning(s)
5
3685
by: Jim Mandala | last post by:
Using Access 2003 front end; SQL Server 2005 Back end: I have a complex form that has lots of data fields including about thirty or so checkboxes storing Yes/No data that I would like my users to be able to use the Filter by Form functionality with to create a "Custom" query. This works perfectly fine when I filter on a text field. Also, this works perfectly fine for all data with an Access Back end. When I use boolean data and my SQL...
2
2640
by: sirdavethebrave | last post by:
Hi guys - I have written a form, and a stored procedure to update the said form. It really is as simple as that. A user can go into the form, update some fields and hit the update button to update the information which is stored in a SQL database. In testing we noticed that the form was updating correctly but the update mechanism was also updating the first record of the table in the sql database every time. No error messages are on...
2
3017
by: swethak | last post by:
hi , i write the code in .htm file. It is in cgi-bin/searches/one.htm.In that i write a form submitting and validations.But validations are not worked in that .htm file. I used the same code in my local system that validations work.plz tell that whats the problem in that. Here is my code <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html...
0
9663
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
9506
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10404
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
10193
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
10136
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
9979
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
9016
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
5415
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2906
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.