Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 5th, 2005, 11:00 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

Welcome to P2P.

Wow, I put that post there a LONG time ago and don't remember the exact circumstances. I suspect the problem lay in that I put the code on the report's ON OPEN event instead of the report's detail section's ON FORMAT event. When you put code in the ON OPEN event having to do with objects in the detail section, they are not initialized yet. Therefore, functions applied to those controls will often fail.


Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
 
Old December 5th, 2005, 11:10 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Another solution would be:

If IsNull(Me.txtMyText) Or Me.txtMyText = "" Then
...

Since some fields in Access will show a zero length string and not a Null.

HTH


mmcdonal
 
Old December 28th, 2005, 11:42 AM
Authorized User
 
Join Date: Oct 2003
Posts: 75
Thanks: 0
Thanked 0 Times in 0 Posts
Default

A project that I've been working on over the past couple of years has given me the same grief as well. We're using MS Access 2003 as a front-end to IBM DB2 on a mainframe along with a System ODBC DSN.

What we've found is that many of the columns in the DB2 tables have been defined as CHAR, which is a FIXED-WIDTH character field in DB2. This means that, for example, while a contact name field may show "Larry Davis" on a form, a contact name column in the DB2 table may be defined as 30 characters, which makes the actual value equal to:

"Larry Davis "

instead of "Larry Davis", which is would you would typically see with an MS-Jet database using a Text column type or SQL Server using an NVARCHAR, etc.

What happens is that when you tab into a field like this, you will see the leftmost portion of the data, with a big black stripe to the right of the data, containing the number of additional "available positions" that have not been utilized.

In a nutshell, using the original example, my personal failsafe code has been the following:

If IsNull(Me.txtMyText) Or Trim(Me.txtMyText) = "" Then
   MsgBox "The textbox is null.", vbExclamation, "Error!"
Else
   MsgBox "The textbox says " & Me.txtMyText, vbInformation, "FYI"
End If

I would hope that this should cover any situations where a form/report/code
is linked/referencing a table that contains fixed-width text/char columns.

Hope that gives some extra insight, too! :)

Warren


 
Old December 28th, 2005, 12:41 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

That is a standard issue with CHAR fields, which is why VARCHAR is nice.

mmcdonal





Similar Threads
Thread Thread Starter Forum Replies Last Post
Null Value Yasho VB.NET 2002/2003 Basics 1 June 21st, 2007 04:37 AM
How to set Not Null constraint to Null Columns arasu Oracle 1 August 22nd, 2005 10:09 AM
Is A Null Different from Another Null ramk_1978 SQL Language 9 February 12th, 2005 03:18 PM
when to use is Null and =null and"null shoakat Classic ASP Databases 3 October 29th, 2004 01:47 AM
Not Null morpheus SQL Server 2000 12 November 20th, 2003 05:46 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.