Access 2007 /number definition/entry problem, also duplicate records

A

Abay

Hello ... I have a couple of problems, probably with very simple solutions
& I apologise for my lack of knowledge. Am in the process of teaching
myself VBA and hope that my knowledge will be much improved in the near
future.

For now .. I am having a problem defining number fields .. no matter what I
do I cannot enter a number with up to 8 decimal places .. it either rounds
up to 1 or the number entered on the form disappears.

I also need to be able to duplicate 2 or 3 fields from the record entered
previously .. I know I can manually do this by pressing cntrl+single quote
... but how do I do this with code on the "Got Focus" property?


Any help would be most appreciated.

Abay
 
P

Piet Linden

Hello ... I  have a couple of problems, probably with very simple solutions
& I apologise for my lack of knowledge.  Am in the process of teaching
myself VBA and hope that my knowledge will be much improved in the near
future.

For now .. I am having a problem defining number fields .. no matter whatI
do I cannot enter a number with up to 8 decimal places .. it either rounds
up to 1 or the number entered on the form disappears.

I also need to be able to duplicate 2 or 3 fields from the record entered
previously .. I know I can manually do this by pressing cntrl+single quote
.. but how do I do this with code on the "Got Focus" property?

Any help would be most appreciated.

Abay

What data type are you using? Or is this really not a VBA problem?
If you need 8 decimal places, you need some kind of floating point
variable/field type. Either single or double. If you're trying to
put it in anything else, like an integer, a currency data type ...
you'll lose all the significant figures. Of course, there's always
the fun of PRESENTATION, which is different... shows rounding, but
doesn't store a rounded value... so which is it? What are *business
goal* are you trying to achieve?
 
A

Abay

Apologies .. I need to go to 5 or 6 dec places .. for currency conversion ..
the application is for employee expenses ... these employees travel the
world and their expenses need to be converted to the Canadian Dollar, for
accounting purposes.

As far as I remember I tried all data types ... I am so frustrated by my
ignorance ...

Abay


Hello ... I have a couple of problems, probably with very simple solutions
& I apologise for my lack of knowledge. Am in the process of teaching
myself VBA and hope that my knowledge will be much improved in the near
future.

For now .. I am having a problem defining number fields .. no matter what
I
do I cannot enter a number with up to 8 decimal places .. it either rounds
up to 1 or the number entered on the form disappears.

I also need to be able to duplicate 2 or 3 fields from the record entered
previously .. I know I can manually do this by pressing cntrl+single quote
.. but how do I do this with code on the "Got Focus" property?

Any help would be most appreciated.

Abay

What data type are you using? Or is this really not a VBA problem?
If you need 8 decimal places, you need some kind of floating point
variable/field type. Either single or double. If you're trying to
put it in anything else, like an integer, a currency data type ...
you'll lose all the significant figures. Of course, there's always
the fun of PRESENTATION, which is different... shows rounding, but
doesn't store a rounded value... so which is it? What are *business
goal* are you trying to achieve?
 
J

John W. Vinson

Hello ... I have a couple of problems, probably with very simple solutions
& I apologise for my lack of knowledge. Am in the process of teaching
myself VBA and hope that my knowledge will be much improved in the near
future.

For now .. I am having a problem defining number fields .. no matter what I
do I cannot enter a number with up to 8 decimal places .. it either rounds
up to 1 or the number entered on the form disappears.

The default Number datatype is Long Integer - and integers are by definition
whole numbers. View the properties of the field, and use Double (double
precision floating point, about 14 decimals precision and a range from 10^-308
to 10^308 or thereabouts); or Decimal which lets you specify the Precision
(total number of digits) and Scale (number of digits after the decimal).
I also need to be able to duplicate 2 or 3 fields from the record entered
previously .. I know I can manually do this by pressing cntrl+single quote
.. but how do I do this with code on the "Got Focus" property?

I don't know if you can. What you might do instead is set the form control's
DefaultValue property to the current value of the control in its AfterUpdate
event; this will make the value sticky for the next record.
 
A

Abay

Many thanks John for your suggestions and help which is very much
appreciated. Will try out your suggestions.

Abay
 
J

John W. Vinson

Apologies .. I need to go to 5 or 6 dec places .. for currency conversion ..
the application is for employee expenses ... these employees travel the
world and their expenses need to be converted to the Canadian Dollar, for
accounting purposes.

As far as I remember I tried all data types ... I am so frustrated by my
ignorance ...

Currency datatype will give you four decimals (no more, no fewer); Double will
give you up to 14 but will have roundoff error. I'd use Decimal with Precision
18, Scale 6.
 

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

Top