Currency Format in Access 2007

T

Triaphoo

Hello everyone,


I am Access programmer. Now I had a problem that I can't find a way
for a long time.

In the Open event of a form, I give the format of a text box related
with records a value. It is similar with the statement below.

Me.txtChargeExtended.Format = "$#,##0.00;($#,##0.00)"

It works well in Access 2003, but in Access 2007, when I close the
form without changing any thing, Access prompts that "Save changes to
the following objects". I wanted to let this tip disappear. And I
comment out this statement above. It can work well. But I did lose the
currency format setting.



So, do you know a good method in Access 2007? Thank you in advance.
 
A

Allen Browne

I just tried this in Access 2007, setting the Format property of a text box
in the form's Open event. The form closed fine without the prompt.

In what event did you set the property? Or did you do it in design view?
 
T

Triaphoo

Allen,

I set the property in Open event of the form, not in design view. And
I also try it in Current event. The result is same. Actually, I notice
when a field of a table is binded a text box and set the text box
Format will have this problem. The Format value is "Currency" in
design view and after evaluating.

Thanks,
 
A

Allen Browne

Okay, I'm trying to reproduce this.

I have a text box named Amount, bound to a field named Amount, which is a
Currency type field in its table. The field in the table has no Format set,
and neither does the text box. In Form_Open, I have the line:
Me.Amount.Format = "$#,##0.00; ($#,##0.00)"

If I open the form, I can verify that the code ran with:
? Forms(0).Amount.Format
No message when I close the form.

However, if I open the form in Design view first, then switch to Form view
(without making any design changes), then I do get the message.

Is that what you are seeing?
 
T

Triaphoo

Allen,

Thanks for your patience to help me resolve this problem.

Here, my situation isn't same with your steps that reproduce this. In
Access 2003, it works well and without any code change I used the
program in Access 2007. In some forms, I got the save prompt but in
fact I didn't make any change. After investigation, I found the
problem is in the lines that setting some text box Format attribute
from "Currency" to a certain Format.

Here, I want to know why the save prompt will show generally. My
understanding is that some things of a form is changed or updated, or
add/delete a record. If my thought is correct. So what I want to is
that after the statement "Me.Amount.Format = "$#,##0.00;
($#,##0.00)"", we set a attribute or porperty of form and tell it "you
are untouched and don't show me save prompt dialog". So is there this
attribut or property?

Or, changing the text box (using for currency target) format without
wake up form save listener. So what property of text box or form or
Access should I notice?

Thank you.
 
A

Allen Browne

I don't believe Access exposes any property that indicates of the form has
had a design change.

You can work around the problem by closing the form programmatically with:
DoCmd.Close acForm, Me.Name, acSaveNo
But that doesn't work unless the form is closed by code, so doesn't work for
cliking the [x] at the right of the form's title bar, closing Access,
pressing Alt+F4, etc, etc.

Therefore the productive route seems to me to be to understand why the
mesage is being triggered, so you can can avoid that. And if the form is not
opened in design view, I suggest the message is not triggered.
 
T

Triaphoo

Allen,

Finally, I had used your method below to work around the problem.
Users will use a form to confirm their currency.
DoCmd.Close acForm, Me.Name, acSaveNo

Thank you very much! Hopefully, I can do something to express
appreciation to you.
 

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