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

Placing string "None" in blank report textboxes

Hi there...
What is the VBA Code for inserting the string "none", in every blank textbox, in a report?
My system, generates a report from a query. eg: textbox1: FirstName ; textbox2: Middle Name; textbox3: LastName! Now, my report will display everyone's FirstName, MiddleName, LastName from the query. Incase someone does not have a middle-name, I need the word "None", to be displayed, on the the report? How do I go about doing this?
My attempt : If txtMidName.Value = " " Then txtMidName.Value = "None"
But clearly this didn't work
Please Help...
Sep 10 '09 #1
3 2767
FishVal
2,653 Expert 2GB
You could well help yourself debugging your code.
Hint for starters:
  • Put breakpoint on the mulfunctioning code line.
  • Let code run.
  • When execution stops (if ever) on the breakpoint check values returned by properties, variables, expression evaluation results etc involved.
  • ??????
  • PROFIT !!!

Kindest regards,
Fish.
Sep 10 '09 #2
Stewart Ross
2,545 Expert Mod 2GB
Assuming that it is not a fault you are trying to trace - you just want to replace null fields (fields with no content at all) with the word "none" - you need to change the textboxes concerned in your report from being bound to an underlying field to being unbound, then set their control source to a call to the Nz function applied to your original bound field. This is not a VBA issue, and in any event you cannot change the contents of bound report controls using VBA code (although you can of course change the contents of unbound controls).

Say your textbox was called "TextBox2" and its control source is field "Middlename". All you'd need to do is to change the controlsource property to

=Nz([Middlename], "(none)")

Note that it is rare for such a blank field to contain an empty string and not simply be null - there is a considerable difference. If it really does contain an empty string then Nz will not work (as the field is not null) in which case you can use an IIF statement instead:

=IIF([Middlename]="", "(none)", [Middlename])

Please also note that if the name of the textbox is the same as the bound field - which it will be if it was created by the report wizard - you must change it to a name that does not clash with the name of an existing field or an error will result.

-Stewart
Sep 10 '09 #3
Stewart Ross
2,545 Expert Mod 2GB
Final thought from me on this one is that it is often a more general approach to put such computed fields into your report's source query (using the IIF or Nz approach as necessary), then use the computed field in your report instead of the potentially blank one. This has the benefit that you create the computed field just once and can use it wherever you use your query - in a form, a report or whatever.

The choice is yours...

-Stewart
Sep 10 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Sam Sungshik Kong | last post by:
Hello! I use Python for ASP programming. I found something weird. Response.Write(Request("something")) It draws "None" when there's no value for something. Actually I expect "" instead of...
13
by: Dan R Brown | last post by:
I have a large form that is generated dynamically in a jsp using xml / xslt. So, to break up this form into several "tabbed" sections, I break up the form using <div> tags. Each <div...
5
by: Daniel Crespo | last post by:
Is there a built-in method for transforming (1,None,"Hello!") to 1,None,"Hello!"? Thanks
5
by: Sue | last post by:
Help! I have an asp table with an embedded table. The asp tablerow that contains this table has a static ID assigned of "FilterRow2" (see snippets of code below). When I click on the button to set...
5
by: z. f. | last post by:
sorry about the previous post, by mistake not completed. i have an asp.net page with the line <%@ OutputCache Duration="30" VaryByParam="none" %> but when i make requests to the page with...
2
by: Nathan Sokalski | last post by:
I have several DropDownList controls on my page that use databinding. However, I want to give users the option of selecting a choice such as "None Selected" or something else that shows they did...
3
by: Stan Brown | last post by:
Posted by Pierre Blais in the current RISKS Digest: http://catless.ncl.ac.uk/Risks/24.24.html#subj9 -- Stan Brown, Oak Road Systems, Tompkins County, New York, USA http://OakRoadSystems.com/...
2
by: spifster | last post by:
Hello all, I am building a collapsable tree using Javascript with DOM in IE. In order to make collapsed cells disappear I have been hiding the text. The cells collapse but still leave borders...
2
by: Good Man | last post by:
Hi there I have quite a bit of experience with CSS but I am stumped by the following: http://www.electricphase.com/example/example1.php (uses http://www.electricphase.com/example/test1.css) ...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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...
0
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,...
0
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...
0
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,...

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.