Update a form with a Command Button

  • Thread starter Thread starter Alimbilo
  • Start date Start date
A

Alimbilo

How can I have a Command Button to execute all the code I wrote in a form?
 
Two ways:

1. Put the code in the button's Click event procedure.

2. Put the code in a Private function in the form's Module, or a Public
function in a standard module if you want to use the same code elsewhere in
the database. Then call the function from the button's properties sheet as
the On Click event property of the button:

=YourFunctionName()

Ken Sheridan
Stafford, England
 
Thanks,

My other question is how can I have a field to show me the exact number.
What I meant is, I am trying to divide 400 / 104 and the field is giving me
4.00 as an answer but I want it to show me 3.85

Thanks
 
If the result is shown in an unbound control on then you need to set the
Format property of the control to show however many decimal places you want
to show. The following would format the control to show two decimal places
and to use a comma as the separator for values of one thousand or more:

#,##0.00

If the control is bound to a field in the underlying table then the field
should be defined in the table design as a single or double precision
floating point number data type, not an integer (by default number fields are
long integers). However, if the calculated value can always be derived from
other fields in the table then it should not be stored in a field at all.
That constitutes redundancy and leaves the table open to the risk of
inconsistent data being entered. The value can always be obtained by means
of a computed unbound control in a form or report, or by a computed column in
a query.

Ken Sheridan
Stafford, England
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top