473,396 Members | 2,024 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,396 software developers and data experts.

Setting control properties

I'm having trouble setting decimal place values in the results field
of a sample management database I'm building for an environmental
testing laboratory. The degree of sensitivity varies among test
methods; consequently, some results are reported to 2 decimal places,
some to 3, etc. The Results subform consists of Test Parameter,
Result, Report Unit, Analysis Date, Analyst and other fields. The
test parameter control is a drop-down box. I created a test parameter
after_update event using Select Case relating the test parameter ID
number and the Result.DecimalPlaces property. When I select a test
parameter and proceed to enter a test result, the result is formatted
to the proper decimal place value. When I add new records, however,
and choose a test parameter with a different decimal place value, all
the test result values change to the decimal place value assigned to
the most recent entry. Obviously my knowledge of VBA is minimal,
because I can't solve what I'm sure is an elementary problem. I would
appreciate , in addition to a simplified explanation of my problem,
any recommendations on an entry level book for VBA. Thanks in advance
for your response.
Nov 12 '05 #1
2 3724
John,

Your problem comes down to how forms work.

Single Form ----------
A single form contains one set of controls and as the form navigates from record
to record, the controls fill with the data from the recordsource of the form
from the fields the controls are bound to. Given that there is only one set of
controls, each control can have only one format and as the form navigates from
record to record, all the data displayed has the same format. In other words, if
you set the decimal places to two for a certain control (textbox), when you
navigate from record to record, all the data displayed in that control will have
two decimal places.

Continuous Form ---------------------
When you look at a continuous form, you see one set of controls in the detail
section. When the form opens in form view and displays all the records from the
recordsource, there is still only one set of controls. What you see are multiple
instances of the same set of controls. Again, given that there is only one set
of controls, each control can have only one format. Each instance mirrors that
same set of controls so the data displayed in each instance has the same format.
In other words, if you set the decimal places to two for a certain control
(textbox), the data displayed in that control in each instance will have two
decimal places.

Given how forms work, you can't display data for different records in the same
texbox with different decimal places without doing something extra. In you case,
that something extra is probably writing a function to format the result in the
textbox after it has been entered. The function would have to apply an
appropriate format depending upon the test that produced the result. You would
use the Format function within this function. The format function would look
like:
Format([Result],"##0.00") to get two decimal places, or
Format([Result],"##0.000") to get three decimal places.
# indicates there may or may not be a number at that placeholder while 0 fills
the placeholder with a 0 if nothing was entered for that placeholder.
--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
re******@pcdatasheet.com
www.pcdatasheet.com

"John Hargrove" <jr********@comcast.net> wrote in message
news:82**************************@posting.google.c om...
I'm having trouble setting decimal place values in the results field
of a sample management database I'm building for an environmental
testing laboratory. The degree of sensitivity varies among test
methods; consequently, some results are reported to 2 decimal places,
some to 3, etc. The Results subform consists of Test Parameter,
Result, Report Unit, Analysis Date, Analyst and other fields. The
test parameter control is a drop-down box. I created a test parameter
after_update event using Select Case relating the test parameter ID
number and the Result.DecimalPlaces property. When I select a test
parameter and proceed to enter a test result, the result is formatted
to the proper decimal place value. When I add new records, however,
and choose a test parameter with a different decimal place value, all
the test result values change to the decimal place value assigned to
the most recent entry. Obviously my knowledge of VBA is minimal,
because I can't solve what I'm sure is an elementary problem. I would
appreciate , in addition to a simplified explanation of my problem,
any recommendations on an entry level book for VBA. Thanks in advance
for your response.

Nov 12 '05 #2
You should really consider a separate VBA function to format the
result values for the test. As you have seen, you cannot use the
DecimalPlaces property on a control on a continuous form to show
results with different decimal places. Consider using a separate
unbound calculated control adjacent to the result field, which uses
your function to display the properly formatted result. The result
value field's AfterUpdate event should requery the calculated control
so it is updated automatically. You will also need to use the same
function on your reports. At a minimum, the parameters to your
formatting function are the result value and the number of decimal
places. All of your result value formatting can be performed in this
single function so you can enhance its features over time. For
example, when you discover you also need significant figure rounding,
which is not the same as decimal place rounding, you can add it to
your formatting function.

The Visual Basic Programmer's Guide that comes with Office is a good
place to start learning VBA. You should also consider the Access
(appropriate version) Developer's Handbook by Litwin, Getz, et al.
which has plenty of Access-specific VBA examples. HTH

Rick Collard
www.msc-lims.com

On 10 Dec 2003 14:58:01 -0800, jr********@comcast.net (John Hargrove)
wrote:
I'm having trouble setting decimal place values in the results field
of a sample management database I'm building for an environmental
testing laboratory. The degree of sensitivity varies among test
methods; consequently, some results are reported to 2 decimal places,
some to 3, etc. The Results subform consists of Test Parameter,
Result, Report Unit, Analysis Date, Analyst and other fields. The
test parameter control is a drop-down box. I created a test parameter
after_update event using Select Case relating the test parameter ID
number and the Result.DecimalPlaces property. When I select a test
parameter and proceed to enter a test result, the result is formatted
to the proper decimal place value. When I add new records, however,
and choose a test parameter with a different decimal place value, all
the test result values change to the decimal place value assigned to
the most recent entry. Obviously my knowledge of VBA is minimal,
because I can't solve what I'm sure is an elementary problem. I would
appreciate , in addition to a simplified explanation of my problem,
any recommendations on an entry level book for VBA. Thanks in advance
for your response.


Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Jason Butera | last post by:
I know that I can read/write custom properties of an object by using the following: Setting: document.all.customProp = "this"; Getting: document.all.customProp; Is there a way I can run...
18
by: Dixie | last post by:
Can I set the Format property in a date/time field in code? Can I set the Input Mask in a date/time field in code? Can I set the Format of a Yes/No field to Checkbox in code? I am working on...
3
by: countd4 | last post by:
I have built a working user control. However, to make it work, I always have to set certian properties using the properties sheet for the control when using it on other forms. I want to be able to...
6
by: Angel | last post by:
I have a button, combo, and custom control that i created. When I click the button i want to set certain display properties of my custom control depending whats in the combo. I set those properties...
1
by: Rob Meade | last post by:
Hi all, I have a loop in my code which builds the controls on the page. I at one stage need to add some hidden input controls dynamically, I have achieved this, and I have set their...
8
by: David Lozzi | last post by:
Howdy, I have a user control that is a report to display data. On the page the control is inserted in, I have filter options to filter the report. When I try to do something like this, nothing...
3
by: cleo | last post by:
In VB6 my practice was to set control properties at Run Time rather than Design Time. I found setting property values in the code provided better documentation, since much of this was hidden - and...
3
by: Mark Rae | last post by:
Hi, Just a general quickie on setting properties of user controls from the parent form. Let's say I have a user control called note.ascx which displays a datagrid. That datagrid is populated...
7
by: Ronald S. Cook | last post by:
In a .NET Windows app, if I set somehting like the title of the form to "MyApp" at run-time, will that make the app run slightly slower than if I had set the title at design-time? Thanks, Ron
6
by: | last post by:
I have made some user controls with custom properties. I can set those properties on instances of my user controls, and I have programmed my user control to do useful visual things in response to...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.