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
|