ctl.Text --vs-- ctl.Value

For Each ctl In Me.Section(acHeader).Controls
  --code--
Next ctl

For an unbound textbox control in the header section of my form...
ctl.Text stores "100" which is what I typed
ctl.Value is null

Why?

What is the difference in these properties?


-- 
Regards,
John
0
Utf
3/13/2008 7:11:01 PM
access.formscoding 7493 articles. 0 followers. Follow

2 Replies
1038 Views

Similar Articles

[PageSpeed] 38

You will very rarely if ever need to use .text in your code.

you'll often see some amateurs write the following code

me.MyTextBox.SetFocus
msgbox "the value is " & me.MytextBox.Text

The problem is with the use of the dot text property, it is only valid and 
legal to use while the  control has the focus. sometimes it takes some new 
developers to access a better time to figure this out, you'll often see 
hundreds of lines of code where they want to get, or set the value of a 
controlled so we have Williams and billions of set focus commands plastered 
all over.

of bout the only time you'll ever use .text is when you're doing some coding 
with the on change event of a control (since the text will not have been 
written from the text box to the actual "value".

for 99% of all other code, you simply are going to use the .value property. 
(and of course the .value property does not need the focus either).

I should point out that the .value property is in fact the default property 
of the control, so a lot of us developers actually just leave out the.value 
for most of our code....

msgbox "the value is " & me.MyTextbox


-- 
Albert D. Kallal    (Access MVP)
Edmonton, Alberta Canada
pleaseNOOSpamKallal@msn.com\ 


0
Albert
3/13/2008 7:22:05 PM
I discovered my issue with .text having "100" and .value being null was 
caused by interactive debugging.

Still there is a problem, but im starting a seperate thread to ask a new 
question :)
-- 
Regards,
John


"Albert D. Kallal" wrote:

> You will very rarely if ever need to use .text in your code.
> 
> you'll often see some amateurs write the following code
> 
> me.MyTextBox.SetFocus
> msgbox "the value is " & me.MytextBox.Text
> 
> The problem is with the use of the dot text property, it is only valid and 
> legal to use while the  control has the focus. sometimes it takes some new 
> developers to access a better time to figure this out, you'll often see 
> hundreds of lines of code where they want to get, or set the value of a 
> controlled so we have Williams and billions of set focus commands plastered 
> all over.
> 
> of bout the only time you'll ever use .text is when you're doing some coding 
> with the on change event of a control (since the text will not have been 
> written from the text box to the actual "value".
> 
> for 99% of all other code, you simply are going to use the .value property. 
> (and of course the .value property does not need the focus either).
> 
> I should point out that the .value property is in fact the default property 
> of the control, so a lot of us developers actually just leave out the.value 
> for most of our code....
> 
> msgbox "the value is " & me.MyTextbox
> 
> 
> -- 
> Albert D. Kallal    (Access MVP)
> Edmonton, Alberta Canada
> pleaseNOOSpamKallal@msn.com\ 
> 
> 
> 
0
Utf
3/13/2008 7:43:02 PM
Reply:

Similar Artilces:

Proper Text in Userform Text Box
I've built a fairly simple user form with text boxes and combo boxes that inputs values onto a spreadsheet upon closing the userform with a command button Two of the text boxes are for Name and Surname. How can I 'Proper' the text after the user has tabbed on to the next box or closes the user form with the command button? Hi you could use application.proper und the textbox entry -- Regards Frank Kabel Frankfurt, Germany "Anthony Slater" <AnthonySlater@discussions.microsoft.com> schrieb im Newsbeitrag news:201F6E72-A57A-4D2A-9BE0-6A60749C8BD3@microsoft.com.....

Pie chart
Windows 2000 Office 2000 I have a pie chart with the distribution of volumes by region. The labelling options in Excel will let me choose to show value, label, or label and %. I want to show label and VALUE. Tried using the XYLabeler program, but it just replaces existing labels. Does anyone know how to show label and value on a pie chart? Thanks in advance for any help! Rita Palazzi Senior Engineer/FedEx Express Rita - Make a label in another range of cells that combines label and value: =[cell address with label]&" - "&[cell address that contains value] Now ...

How do I mix text justification within the same line of text?
The paragraph format seems to affect the entire line of text, I want the first word in the line to be justified to the left and the second word of that same line to be justifed to the right (margins) Tabs Create or modify a tab stop http://office.microsoft.com/en-us/assistance/HP051150711033.aspx -- Mary Sauer MSFT MVP http://office.microsoft.com/ http://msauer.mvps.org/ news://msnews.microsoft.com "Lost in the first line" <Lost in the first line@discussions.microsoft.com> wrote in message news:75BA686A-3CA7-4F13-B33E-2F8771C1E111@microsoft.com... > The paragraph form...

Text add-in
Good morning all I have just installed the add-in morefunc.dll so I can convert a number into text format, however, now it's installed, I don't know how to use it!!!! Can anybody shed any light??? Thanks. Louise. The extra functions can be used in the same way as other Excel functions. The one for number-to-text is called NBTEXT. It's full syntax is: =NBTEXT(Number,Language,Type,Unit1 (sing),Unit1 (plur),Unit2 (sing),Unit2 (plur),Style,Gender1, Gender2) You can see full details in the morefunc help file. Selct Insert>function (or click fx button). Select the Morefunc ca...

Cmd Click --- check the values first,append record and then delete them.
Hi all, I want to execute below code but it seems absolutely fail, please help: Private Sub AddSpec_cmd_Click() On Error GoTo Err_AddSpec_cmd_Click If IsNull(Me.Model) Then MsgBox " Enter Model Name", vbOKOnly, "Model name empty" End If Model.SetFocus If Inputvoltage.Value < 11 Then MsgBox " Input correct voltage rate ", vbOKOnly, "Input voltage" End If Dim db As Database Set db = CurrentDb db.Execute "Appendix model spec1_qry", dbFailOnError db.Execute &quo...

Retrieving value from parent object using jscript
Is there any way to retrieve a value from a parent object in jscript? For example, if on the contact form I wanted to be able to validate a field dependant on the account.accountcategorycode - is there a way for me to retrieve the value in jscript so I can do the necessary logic? Any help much appreciated. ...

excel
I experimented with Text to Voice and now I CANNOT TURN IT OFF! It operates in every spreadsheet and in every cell - it is driving me nuts! Please - how do you stop it! - the toolbar does not work - it stops it if I am quick enough for the one cell but carries on in all the rest!*! Thanks Ally64000@yahoo.co.uk Go 'View' > 'Toolbars' > check 'Text to speech' and the toolbar will appear Toggle the icon on the right, 'Speech on enter' to off Regards, "ally" <anonymous@discussions.microsoft.com> wrote in message news:079701c46e53$e386cde0...

I need to carry over text to the next row.
I have Excel 2003 and I have figured everything else out except for how to carry text over to the next row when I reach the end of the previous row. And at the end of the last row, I'd like to have it automatically go to the second page onto a specific line. Thanks. Not sure exactly what you're trying to do, but you may be looking for wrap text. Go to Format - Cells - Alignment tab and check the Word Wrap checkbox. You can also highlight multiple adjoined cells and merge cells to allow for a larger input space. Not sure what you mean by end of last row, go to next page. Looki...

Property ctl.Value not set when...
Property ctl.Value not set when...Pressing Enter The form I am working with is a search routine using unbound text boxes in the header for the criteria. I have set up the form to detect keypresses: Enter or Esc in the Form_Keydown routine and call the search routine that is stored in a cmdFilter_Click (or the cmdReset_Click for the Esc key) I think what is happening is that the KeyDown event is firing before the search text has been registered into the .Value propery of the control. Because, If I press Enter again after no search critera were recognized, the routine then sees the .v...

Mapping estimated value to totalamount
Hi, I define a map between opportunity estimated revenue and quote totalamount. I set the estimated revenue to be user provided and write a value by hand. The value is not carried to the totalamount field of the quote when I add a related quote. Instead it is calculated from the amount fields of the quote products. Is the totalamount field always system calculated, cannot we override it with the value in the estimated revenue? Thanks, Bilge Gul "b_gul_t" <bgult@discussions.microsoft.com> wrote in message news:840D5F58-34E8-4639-9A8C-C0508D9C9686@microsoft.com... > ...

How can I embed a font in an Excel text box?
...

Adding value to drop down list
I have a drop down list that functions using codes to determine a rat of pay by the hour. However, a couple of times a year, the payrol people pay lump sum payments that can vary. Is there a way to write drop down list with a "blank" so that the user's own data (amount to b paid) of an amount not specified in the drop down list can be added i by the user? Thanks for any advice in advance -- ne ----------------------------------------------------------------------- neb's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=1759 View this thread: http:/...

That old #VALUE! problem
I have made up a spreadsheet that has lots of cells with IF formulas but I want the result of those cells to add up as a total. However, no matter how I try, the total cell keeps coming out with the dreaded #VALUE!. All the IF formulas are fine and work well but I need them all to add up but show nothing in the cell unless there is a value worked out in the original IF cells. Hope that's clear and that someone can help. I am using OFFICE2000. Nick What exactly is your formula? If you don't show us the formula that creates the problem we can't identify the problem, Any...

Converting Numerical Values Into Text #2
Genius! I've just tried it, and it worked (I had to copy and past special into a text formatted column before it would import into custom list, but it worked). Thank you so much! Cle -- cleadavi ----------------------------------------------------------------------- cleadavis's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=1658 View this thread: http://www.excelforum.com/showthread.php?threadid=31446 ...

2nd Posting Select Value In Query
My data are as follow Myvalue value1 value2 value3 100 20 50 70 200 null 100 210 my goal is to divide myvalue with either value 1,2 or 3 whichever is higher how to put the expression in query Zyus - Here is what will go in the SELECT field of your query: =Iif(nz(value1,0)>nz(value2), Iif(nz(value1,0)>nz(value3,0),Myvalue/value1,Myvalue/value3), Iif(nz(value2,0)>nz(value3,0),Myvalue/value2,Myvalue/value3)) If value1 and value2 and value3 could all be null or zero, then you must test for that (I am assum...

vertical text not drawn at correct location
The code below illustrates the problem I am having. A rectangle is drawn in the center of the display. Text is suppose to be drawn at a 270 degree angle and centered in the middle of the rectangle. Instead, the text is always drawn to the far to the left of the rectangle. If I change text escapement to 0 degrees then the text is correctly centered. Can someone suggest what mistake I am making? Thanks in advance. Ian CMyView::OnDraw( CDC *pDC ) { // create font CFont oFont; LOGFONT oLF; memset( &oLF, 0, sizeof(oLF) ); oLF.lfHeight = 25; oLF.lfOrientation = ...

Formating Text in a List Box
How do I increase or format the text in a list box? Thanks! In the Properties Box you can set the Font, Style and Size. PC "PSTEWART" <PSTEWART@discussions.microsoft.com> wrote in message news:C26CF8F6-8C68-4809-9F49-54041CCCE9B1@microsoft.com... > How do I increase or format the text in a list box? Thanks! Thanks for your post. When I create a "list box" from the Forms toolbar, the properties box does not have any options to change the font size. I am assuming that the text size is set to the default text (font and size) of the workkbook.. "PC&...

Worksheet diplays formulas and not the calculated values.
My workshhet displays the formula that I entered (Vlookup) and is not displaying the values of the function. Formatted cells to numbers, copied formula from a worksheet that dispalys values etc etc but nothing is working. How could I resolve this? Sounds like an Excel question and this news group is for Access. Try putting an equal sign in front of the formula. -- KARL DEWEY Build a little - Test a little "Ann" wrote: > My workshhet displays the formula that I entered (Vlookup) and is not > displaying the values of the function. > > Formatted cells to numbers...

Text Formatting when using CONCATENATE
I have several columns of data and I'm using the CONCATENATE function to combine the data into one column on the right, which is simple enough. But I need to extend on this by keeping the formatting of the text as it appears in the original columns. For example, if Column A is Bold (*ONE*), but Column B is italic (-TWO-), how can I have the text in the result column keep the original formatting (*ONE* -TWO-). This is a problem which has had me lost for ages, so any help or suggestions would be greatly appreciated. Steve --- Message posted from http://www.ExcelForum.com/ Steve, You ...

If query/subform is empty set calculation value to 0
Using a subform, I am summing a field across multiple records, then adding multiple subform totals to provide a single total on the main form. However, in some cases, some subforms may not return any records (Due to no records existing for the item), and in this case, i get a #Error response, and the rest of the calculations on the main form fails. How do I check to see of the table is empty, and if so return a zero value, otherwise, return the sum value being sought? Tony Consider using queries to fill the forms/subforms. Then use the Nz() function in your query to conver...

REVERSING TEXT
HOW CAN I REVERSE TEXT AND PICTURES ON PUBLISHER TO PRINT ONTO T.SHIRTS spike <spike@discussions.microsoft.com> was very recently heard to utter: > HOW CAN I REVERSE TEXT AND PICTURES ON PUBLISHER TO PRINT ONTO > T.SHIRTS YES. PLEASE READ REPLY TO YOUR FIRST POST. Please do not talk in all caps. It is considered shouting and makes your post difficult to read and is rude. Your first message ("how do i reversie pictures and text for printing to t.shirts") is directly below this one and has been answered by yours truly. -- Ed Bennett - MVP Microsoft Publisher ...

Convert all cells contents in the sheet to values
I have a spread sheet at work that is linked up to other sheets. We keep the sheets on a shared drive so that everyone can make their updates. The main sheet which I operate is just linked to the others and picks up everybody's updates. Twice a week, I need to email this out to my boss. Is there a general function which converts all cells contents in the sheet to values that I can use before I sent this? I know the Paste Special feature can be used for this, but I have a lot of sheets and I want to get it done with a single keystroke. Isn't there a Save feature that simply writes out a...

XML Serialisation of value/built in types
Hi, When I try to use the XMLSerializer class to serialize an object with simple types, I get node names that are the "basic" versions of the type names, ie: string testString = "hello world"; XmlSerializer ser = new XmlSerializer(testString.GetType()); StringWriter sw = new StringWriter(); XmlTextWriter xw = new XmlTextWriter(sw); ser.Serialize(xw,testString ); ....i get: <?xml version="1.0" encoding="utf-16"?><string>hello world</string> ....but what I would like is the full name of the type (ie the same as if I called string.G...

Vertical text in label
How do I enter vertical text in an label in Access? I would like the text to be read vertically instead of horizonally. S h i instead of Ship p Thanks See what Stephan Lebans has at http://www.lebans.com/verticaljustification.htm -- Good Luck BS"D "newbie35" wrote: > How do I enter vertical text in an label in Access? I would like the text to > be read vertically instead of horizonally. > S > h > i instead of Ship > p > > Thanks ...

incremenT CountIF Value
Hi, i have the following COUNTIF formula - the range stays the same but th value its searching for changes each time going up to 100 - i don' really want to type in 1 -100 in my seperate count if functions i there a better way? Many Thanks =COUNTIF(A:A,"1") =COUNTIF(A:A,"2") =COUNTIF(A:A,"3" -- infojma ----------------------------------------------------------------------- infojmac's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=1078 View this thread: http://www.excelforum.com/showthread.php?threadid=27313 Assuming your va...