MSAccess

C

chad

I have developed a macro in my program. I have 2 fields, the 1st is a text
field and the 2nd is a number field. the macro is set up so when I place a
number in the TEXT field it automatically puts the same in the Number field
(so I can later add this field with another). Example: 195++ is placed in the
1st field (text) and it puts 195 in the 2nd field (number only).

Problem: when I do enter the 195++ in the 1st field, the 195 does not show
in the Number field until I close the form and then reopen it (I have
attempted to set the event that causes the macro to start several ways -
before update, after update, on entry, etc. to no avail).
 
J

John W. Vinson

I have developed a macro in my program. I have 2 fields, the 1st is a text
field and the 2nd is a number field. the macro is set up so when I place a
number in the TEXT field it automatically puts the same in the Number field
(so I can later add this field with another). Example: 195++ is placed in the
1st field (text) and it puts 195 in the 2nd field (number only).

Problem: when I do enter the 195++ in the 1st field, the 195 does not show
in the Number field until I close the form and then reopen it (I have
attempted to set the event that causes the macro to start several ways -
before update, after update, on entry, etc. to no avail).

Care to post the steps of your macro?

It might also be interesting to explain why you feel that you need to store
this information redundantly. If you have it in the text field, you can come
up with an expression such as

Val([textfield])

to extract the number portion at any time, without any need to store it in a
second field.
 
S

Saad Hashmi

You have to requery. Or refresh.
Call the macro from a VBA code.
After calling the macro, the thing you should do in the same VBA code is
something like Me.Requery() or Me.Refresh(), that should refresh all the
data in the available fields on the form.
 
C

chad

Redoing message as I got an error message so not sure if you got my previous.
Macro: Condition: [Sat Score]="180+ (just a sample score). Set Value: Item:
[SatOpenB Score]. Expression: "180". [Sat Score] is a text field. [SatOpenB
Score] is a number field. When I enter the number 180+ in the text field [Sat
Score], the macro places 180 in the number field [SatOpenB Score] (the same
process is done for the 2nd field).
My database needs to have a field that takes both numbers and text (that
field needs to allow entry of Numbers, Numbers with pluses, excused, absent,
and nonqualifed, etc. And for 2 areas I need a field for adding scores from 2
different fields. So I set up a query for Saturday and Sunday where the query
adds the scores: [SatOpenB Score]+[SatUtilityB Score].

From the little experience with Access, I find you cannot add 2 numbers
placed in a text field. So I set up this number field so the 2 scores from
these 2 classes are added for High Combined ( a total of scores from the Open
B class and Utility B class).
--
Chad


John W. Vinson said:
I have developed a macro in my program. I have 2 fields, the 1st is a text
field and the 2nd is a number field. the macro is set up so when I place a
number in the TEXT field it automatically puts the same in the Number field
(so I can later add this field with another). Example: 195++ is placed in the
1st field (text) and it puts 195 in the 2nd field (number only).

Problem: when I do enter the 195++ in the 1st field, the 195 does not show
in the Number field until I close the form and then reopen it (I have
attempted to set the event that causes the macro to start several ways -
before update, after update, on entry, etc. to no avail).

Care to post the steps of your macro?

It might also be interesting to explain why you feel that you need to store
this information redundantly. If you have it in the text field, you can come
up with an expression such as

Val([textfield])

to extract the number portion at any time, without any need to store it in a
second field.
 
J

John W. Vinson

Redoing message as I got an error message so not sure if you got my previous.
Macro: Condition: [Sat Score]="180+ (just a sample score). Set Value: Item:
[SatOpenB Score]. Expression: "180". [Sat Score] is a text field. [SatOpenB
Score] is a number field. When I enter the number 180+ in the text field [Sat
Score], the macro places 180 in the number field [SatOpenB Score] (the same
process is done for the 2nd field).
My database needs to have a field that takes both numbers and text (that
field needs to allow entry of Numbers, Numbers with pluses, excused, absent,
and nonqualifed, etc. And for 2 areas I need a field for adding scores from 2
different fields. So I set up a query for Saturday and Sunday where the query
adds the scores: [SatOpenB Score]+[SatUtilityB Score].

From the little experience with Access, I find you cannot add 2 numbers
placed in a text field. So I set up this number field so the 2 scores from
these 2 classes are added for High Combined ( a total of scores from the Open
B class and Utility B class).

Well...

You can do arithmatic with numbers.
You cannot do arithmatic with text strings.

"Absent" + 150

does not have any mathematical meaning.

You'll probably need to write a bit of VBA code to convert strings to numbers,
do math with them, and convert them back to strings. I don't use Macros much
at all so I'm not sure how or if you can do so, or how. Maybe you should
repost in the microsoft.public.access.macros group.
 

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