A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Appending zero-length string



 
 
Thread Tools Display Modes
  #1  
Old February 18th, 2010, 08:11 PM posted to microsoft.public.access.queries
Claire
external usenet poster
 
Posts: 132
Default Appending zero-length string

Hello all,
I recently ran Allen Browne's function to change all my fields to not accept
zero-length strings- which makes so much sense to me. Of course, I'm now
feeling some repercussions.

I have a command button on a form that runs an append query. This query
includes two fields which are not required, and which access seems to append
as zero-length strings if they are blank on the form. Is there a way to
change the query to append a null value if it is blank, or in other words, to
only append data that has values? Or should I pull out the saved query and
use VBA to append the values depending on what is blank on the form?

It seems a shame to allow zero-length strings if I'm appending into them,
when everything else is going to be clean.

Thanks for you suggestions,
Claire

  #2  
Old February 18th, 2010, 09:21 PM posted to microsoft.public.access.queries
John Spencer
external usenet poster
 
Posts: 7,815
Default Appending zero-length string

Care to post the query or the code you are using? It is really difficult to
trouble-shoot without the needed information.

IF you are building the query string, you probably need to put the word NULL
into the string when the control has a null or zero-length string value.


John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County

Claire wrote:
Hello all,
I recently ran Allen Browne's function to change all my fields to not accept
zero-length strings- which makes so much sense to me. Of course, I'm now
feeling some repercussions.

I have a command button on a form that runs an append query. This query
includes two fields which are not required, and which access seems to append
as zero-length strings if they are blank on the form. Is there a way to
change the query to append a null value if it is blank, or in other words, to
only append data that has values? Or should I pull out the saved query and
use VBA to append the values depending on what is blank on the form?

It seems a shame to allow zero-length strings if I'm appending into them,
when everything else is going to be clean.

Thanks for you suggestions,
Claire

  #3  
Old February 18th, 2010, 11:51 PM posted to microsoft.public.access.queries
KenSheridan via AccessMonster.com
external usenet poster
 
Posts: 1,610
Default Appending zero-length string

Clai

An expression in the query such as the following:

IIF(TRIM(Forms!YourForm!YourControl & "")="",NULL,Forms!YourForm!YourControl)

would return a Null if the control is Null, contains a zero-length string, or
a string made up entirely of space characters, but the value of the control
otherwise.

Ken Sheridan
Stafford, England

Claire wrote:
Hello all,
I recently ran Allen Browne's function to change all my fields to not accept
zero-length strings- which makes so much sense to me. Of course, I'm now
feeling some repercussions.

I have a command button on a form that runs an append query. This query
includes two fields which are not required, and which access seems to append
as zero-length strings if they are blank on the form. Is there a way to
change the query to append a null value if it is blank, or in other words, to
only append data that has values? Or should I pull out the saved query and
use VBA to append the values depending on what is blank on the form?

It seems a shame to allow zero-length strings if I'm appending into them,
when everything else is going to be clean.

Thanks for you suggestions,
Claire


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...eries/201002/1

  #4  
Old February 19th, 2010, 02:17 PM posted to microsoft.public.access.queries
Claire
external usenet poster
 
Posts: 132
Default Appending zero-length string

Beautiful! That should do the trick!

"KenSheridan via AccessMonster.com" wrote:

Clai

An expression in the query such as the following:

IIF(TRIM(Forms!YourForm!YourControl & "")="",NULL,Forms!YourForm!YourControl)

would return a Null if the control is Null, contains a zero-length string, or
a string made up entirely of space characters, but the value of the control
otherwise.

Ken Sheridan
Stafford, England

Claire wrote:
Hello all,
I recently ran Allen Browne's function to change all my fields to not accept
zero-length strings- which makes so much sense to me. Of course, I'm now
feeling some repercussions.

I have a command button on a form that runs an append query. This query
includes two fields which are not required, and which access seems to append
as zero-length strings if they are blank on the form. Is there a way to
change the query to append a null value if it is blank, or in other words, to
only append data that has values? Or should I pull out the saved query and
use VBA to append the values depending on what is blank on the form?

It seems a shame to allow zero-length strings if I'm appending into them,
when everything else is going to be clean.

Thanks for you suggestions,
Claire


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...eries/201002/1

.

  #5  
Old February 19th, 2010, 06:31 PM posted to microsoft.public.access.queries
David W. Fenton
external usenet poster
 
Posts: 3,373
Default Appending zero-length string

"KenSheridan via AccessMonster.com" u51882@uwe wrote in
news:a3d6f81d91b92@uwe:

An expression in the query such as the following:

IIF(TRIM(Forms!YourForm!YourControl &
"")="",NULL,Forms!YourForm!YourControl)

would return a Null if the control is Null, contains a zero-length
string, or a string made up entirely of space characters, but the
value of the control otherwise.


Or you could use a ZLS-To-Null function, like the one after my sig.

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/

Public Function ZLStoNull(ByVal varInput As Variant) As Variant
If Len(varInput) = 0 Then
ZLStoNull = Null
Else
ZLStoNull = varInput
End If
End Function
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 08:48 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.