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

Formatting of a field does not get carried over to the form

418 256MB
This is rather a simple problem nevertheless I have been struggling with this. I am sure one of you experts will show me the way to correct this in a flash. Please help.

Two of the many fields in tblGrantFunds are:

FundID
Number (Field Size: Long Integer)
FedRatio Number (Field Size: double, Format: Percent)

A query based on this table is qryGrantFunds which shows the Fed Ratio as nn% (80% for example).

I have a form Sub form sfrmAP that's based on tblAP where I added two text boxes
1) txtFund has this in its control: GrantFundID, Row Source: qryGrantFunds

2) txtFedRatio has this in its control: =cboFund.Column(4)

Formatting of FedRatio shows up as .8 in the form and not as 80%. What am I doing wrong?

Thanks.
Jun 22 '09 #1
4 1561
Stewart Ross
2,545 Expert Mod 2GB
You're not doing anything wrong at all. Access does not actually do much in the way of carrying forward formatting; the form wizard does do so, but if you add textboxes yourself you will need to set the format property for that textbox appropriately yourself.

A word of warning about your combo column reference: you may find that the combo is returning a text value for your FedRatio value, in which case no amount of formatting will do any good (as formats are applied to numeric values, not text ones). Simple answer in that case is to replace the =cboFund.Column(4) control source with

=CDbl(Nz(cboFund.Column(4), 0))

which will ensure that a floating-point numeric value is being returned. You can then apply a custom format in the Format property of the textbox to display it as a percentage.

The Nz is just ensuring that in the event of a null value in the combo column a text 0 is returned instead. CDbl would otherwise fail on the null value, returning #Error instead.

-Stewart
Jun 23 '09 #2
MNNovice
418 256MB
Stewart:

Wow! It fixed the problem. Thank you thank you thank you so much. I learned a new thing here about Access i.e., floating-point numeric value. What does CDbl do?

Many thanks.
Jun 23 '09 #3
Stewart Ross
2,545 Expert Mod 2GB
Glad to be of help!

CDbl is one of the type conversion functions - in this case convert to double-precision type. I suggested CDbl instead of its counterpart CSng (convert to single-precision) because of the greater number of significant digits which the double-precision type uses (15 instead of 7), as rounding errors can be troublesome in low-precision types. I could have suggested CCur - convert to Currency type - as it does not suffer from rounding errors at all. However, I didn't want to make it more difficult for you in subsequently formatting the value - currencies would by default include the local currency symbol for your area and be formatted to two decimal places, although this can be changed of course.

What is perhaps poorly understood in the use of combo or listbox columns is that the combo is a generic container for values - it is untyped, unlike the underlying field you bind the combo or listbox to in your table.

As text types can be used to represent all kinds of values without having to know in advance what the type really is, combo columns are actually returned as text. They may look like numbers, but they don't behave as numbers. Access will convert these 'on the fly' if, for instance, you feed a column value into a calculation. In your case you were trying to display the value returned by a combo column and it just displayed as it really was - as text. CDbl in this case just converts the text value to a true number ready for formatting or for use in further calculations.

Cheers

Stewart
Jun 23 '09 #4
MNNovice
418 256MB
Stewart: That was really a good elaborate explanation. Thank you.
Jun 24 '09 #5

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

Similar topics

1
by: Doc Wally | last post by:
Dear Colleagues: To begin with I am not a programmer. In fact, I just got all excited because I was able to create my very first .vbs script that actually worked - not that I actually coded...
2
by: Gary | last post by:
Morning all, I have a form field called: Bsk01 How do I onBlur prompt the user to enter a ZERO as character one, if one is not already entered. At the same time, I would like to ensure at...
3
by: Jouke Langhout | last post by:
Hello all! For quite some time now, I've got the following problem: Access won't close properly when a user closes the application. An ACCESS process stays active and that process can only be...
3
by: James | last post by:
Hi, I have a combo box(cmboParts) and the row source is a part name. Once a part is selected I have button(cmdOrderAdd) to add data about this part to a sub-form(frmParts_Ordered). However this...
8
by: Mike MacSween | last post by:
tblCourses one to many to tblEvents. A course may have an intro workshop (a type of event), a mid course workshop, a final exam. Or any combination. Or something different in the future. At...
5
by: Andrew Chanter | last post by:
Does anyone know a way you can use conditional formatting to create a banded style view as is commonly seen on the internet. (In othe words the first record appears on a gray background, the 2nd...
4
by: deko | last post by:
I've heard it's best not to have any formatting specified for Table fields (except perhaps Currency), and instead set the formatting in the Form or Report. But what about Yes/No fields? When I...
8
by: Typehigh | last post by:
I have many text fields with conditional formatting applied, specifically when the condition is "Field Has Focus". Without any events associated with the fields the conditional formatting works...
4
by: slinky | last post by:
Thanks in advance... I have a continuous style form with a field for each record called "STATUS". I simply want to have the form load and if the value of the textbox is "Inactive" I want the...
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:
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.