473,385 Members | 1,344 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,385 software developers and data experts.

Problem testing fieldvalue in form data-entry = yes

Hi,

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

FRM_CONTACT_PERSON_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_NAME 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_NAME triggers error 'invalid use of null" ???

2. if i only enter the CNTP_FUNCTION leaving Me.CNTP_LAST_NAME 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_NAME '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 2134
Filips Benoit wrote:
Hi,

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

FRM_CONTACT_PERSON_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_NAME 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_NAME triggers error 'invalid use of null" ???

2. if i only enter the CNTP_FUNCTION leaving Me.CNTP_LAST_NAME 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_NAME '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_NAME 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_NAME or Me("CNTP_LAST_NAME") 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_LAST_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_PERSON.CNTP_LAST_NAME 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_NAME 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_NAME 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_NAME '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_PERSON 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_NAME = 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@localhost> wrote in message
news:40***********************@auth.uk.news.easyne t.net...
Filips Benoit wrote:
Hi,

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

FRM_CONTACT_PERSON_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_NAME 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_NAME triggers error 'invalid use of null" ???

2. if i only enter the CNTP_FUNCTION leaving Me.CNTP_LAST_NAME 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_NAME '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_NAME 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_NAME or Me("CNTP_LAST_NAME") 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_LAST_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_PERSON 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_NAME = 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.comSPNOAM> wrote in message
news:20***************************@mb-m28.aol.com...
Two things:

1) Make sure that the table.field TBL_CONTACT_PERSON.CNTP_LAST_NAME 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_PERSON 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_NAME = 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_NAME 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_NAME 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_NAME '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....SQL
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
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...
3
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...
1
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...
7
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...
0
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...
2
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...
7
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...
5
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...
2
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...
2
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.