Create Validation Rule for Form Control using VBA or Macro 
Author Message
 Create Validation Rule for Form Control using VBA or Macro

I am a new VBA programmer with moderate experience using
macro's.  Here is what I am trying to do.  I want to
create a Validation Rule property for a Control on a Form
that prevents users from entering a date that is not
between (within) the minimum and maximum date of a
particular field within a table.  I have created 2
seperate simple one field queries to capture the minumum
and maximum dates of this field.  I have tried every which
way to reference the values obtained from the queries
witin the Validation Rule property sheet of the control
with an expression but nothing works.  I must assume then
that I must use a macro or VBA code to accomplish this
task.  What is the best and simplest method of
accomplishing this task?  All suggestions appreciated.  I
want to use this as a learning tool since I have never
tried this before.
THANKS!!!! Van


Mon, 21 Nov 2005 02:48:08 GMT  
 Create Validation Rule for Form Control using VBA or Macro

Quote:
> I am a new VBA programmer with moderate experience using
> macro's.  Here is what I am trying to do.  I want to
> create a Validation Rule property for a Control on a Form
> that prevents users from entering a date that is not
> between (within) the minimum and maximum date of a
> particular field within a table.  I have created 2
> seperate simple one field queries to capture the minumum
> and maximum dates of this field.  I have tried every which
> way to reference the values obtained from the queries
> witin the Validation Rule property sheet of the control
> with an expression but nothing works.  I must assume then
> that I must use a macro or VBA code to accomplish this
> task.  What is the best and simplest method of
> accomplishing this task?  All suggestions appreciated.  I
> want to use this as a learning tool since I have never
> tried this before.
> THANKS!!!! Van

Actually, Vanessa, you don't need to write a special routine for this,
though you could.  This wouldn't work in a validation rule set in the
table design, but for a control on a form you can use a validation rule
like this:

    Between DMin("DateField","tblDates") And
DMax("DateField","tblDates")

where DateField is the name of the field in the table you're verifying
against, and tblDates is the name of that table.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)



Mon, 21 Nov 2005 03:45:14 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. programmatically creating, modifying, or deleting Exchange 2000-based rules using VBA through Outlook 2002

2. VBA code for validation rule

3. VBA and Field Validation Rule Errors

4. Create Custom Rules without using Rules Wizard

5. Using a VBA Macro to copy a VBA Macro

6. Validation rule for to ensure letters are not used in a text field

7. Implementing control level validation rules

8. manually run a specified rule with a vba macro

9. Inbox rule for VBA macro

10. Creating a macro to run rules?

11. creating a rule or vb macro to save messages as HTML

12. start a rule wizard rule with VBA in Outlook 2002

 

 
Powered by phpBB® Forum Software