condition expression type mismatch error

  • Thread starter Thread starter kennethburr
  • Start date Start date
K

kennethburr

I have tried to write a macro in Access 2003 that will result in a
message box when the value in a field is $25,000 or more. The field
type is set to currency. The field name is IHDAconstruction$. The form
name where the macro appears is IHDAProjectsForm. The condition
statement in my macro is
[Forms]![IHDAProjectsForm]![IHDAconstruction$]>=25000. However,
whenever I try to run this macro I get a type mismatch error. I have
tried with and without a $ sign in front of the 25000. I have also
tried with and without quotes around the 25000. And I still get a type
mismatch error. Any help would be greatly appreciated.
 
Hi Kenneth,

I have just replicated your form, using the same field name and form name,
along with macro condition. I used the Before Update event procedure for the
macro. It works fine for me.

If you still cannot get it to work, you might want to try using a validation
rule, with the appropriate validation text, in table design view.

Validation Rule: Between 0 And 24999.99
Validation Text: Please enter a valid dollar amount.


Tom Wickerath
Microsoft Access MVP

http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________
 
Thanks for you quick reply. I also was using the Before Update event
proceedure and either I would get the type mismatch error or the macro
would not run at all. I still don't understand why it doesn't work, but
at least thanks to your suggestion I know I have an alternative.
Thanks very much.
Ken Burr
 
Hi Kenneth,

You're welcome. I'm not a big fan of using macros in any case. In all
current versions of Access, there is no way to trap for errors. This has been
addressed in the next version of Access, which is currently in beta 2 release.

Consider the following quote:

From: "Inside Relational Databases, 2nd Edition, by Mark Whitehorn and Bill
Marklyn, published by Springer, p 151)

"Macros offer the next level down, extending the functionality of the GUI.
Macros are still limited, however, and do not provide anything like the
enormous flexibility of a programming language. Both the macro and the
programming languages take some effort to learn and, surprisingly, often
require relatively different skills; in other words, a good working knowledge
of macros may not make it much easier to convert to using the programming
language. Perhaps even more surprisingly, I do not believe that programming
is fundamentally more difficult to learn. Macros are easier to use but not by
orders of magnitude."

"If you are new to RDBMSs, I suggest (with as much deference as possible)
that you may well not be in a position to judge whether you need macros or
programming. In that case, my advice is clear. Unless you are sure that your
needs really are simple, don't bother learning to use macros. Once you find
that you need more than the GUI offers, go straight to the programming
language. In this way you avoid the pain of climbing one learning curve only
to discover that the view from the top is unsatisfactory and another climb
awaits you."


Tom Wickerath
Microsoft Access MVP

http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________
 

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