Problems with updating a field

  • Thread starter Thread starter Jan Kronsell
  • Start date Start date
J

Jan Kronsell

I have a form with a certain field, called "Rates". This is bound to a tabel
field by the same name. In my form I have a button with the following code:

Select Case Me!kialt.Value - Me!Rabat
Case Is <= 800
Me!Rates = 1
Case Is <= 1600
Me!Rates = 2
Case Is > 1600
Me!Rates = 3
End Select

This works pefectly ok and sets the "rates" field according to the rules.
The button does a lot of other stuff as well that also works OK.

But now my problem. I need to be able to set the rates field manually as
well. Thats is, overriding the setting made by the code. I can do that by
not clicking the butoon afterwards, of course, but how do I prevent users
from clicking the button after manually changing the rates field? Or is
there another way to make sure that changes done manually are not
overwritten by changes done by code?

To additional questions:

Is there anyway I can prevent a user doing anything, besides closing the
application, until he clicks on a certain button? What I want is to make
sure the users always clicks a certain button and nothing else, if they have
made changes to the data. I tried somethin like the Dirty event to disable
other buttons and the let relevant button enable them again, but I cannot
get it to work.

Finally the above code works perfectly, but if i change it to

Select Case Me!kialt.Value - Me!Rabat
Case Is <= 800
Me!Rates = 1
Case Is <= 1600
Me!Rates = 2
Case Else
Me!Rates = 3
End Select

It never gets to the Case Else no matter how big a number the calculation of
Me!kialt.Value - Me!Rabat gets.Any ideas why its so?
 
You can set button's Enabled property to False on textbox AfterUpdate event.

On Form_Current event, you set Enabled = true again.

Luiz Cláudio C. V. Rocha
São Paulo - Brazil
 
I solved the problem by creating another field in both table and form, names
ManRates, where I can type the rates manually, and I'm them comparing the
two filds in my code, selecting ManRates if this fields is not empty.

Jan
 
Your other problem: "Is there anyway I can prevent a user doing anything,
besides closing the
application, until he clicks on a certain button?"

There are different possible solutions. Actually, it depends on the windows
you have opened on the screen. If it's only one, you can set AllowEdits,
AllowDeletions and AllowAdditions properties to False. If you have more than
one window, you must work with a modal window.
You can also use a dialog modal/popup form with the button, or even a
MsgBox. It will prevent the user from doing anything else until he clicks on
the button.

Luiz Cláudio C. V. Rocha
São Paulo - Brazil
 

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