Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login




Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Donate Today!

Do you enjoy these
technical forums?
Donate Today! Click Here

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

MS Access - Form Validation Rule - referencing other forms or tables

Larry1216 (TechnicalUser) (OP)
25 Jan 05 9:44
I want to have a validation rule for a form reference another form or table in the same database.

I have a table [Reference 03 Data For Forms] with a field [RYEndDOS] in the Short Date Format. There is a form [Switchboard] where the user enters a date for the end of the year.

In the validation rule for a date field on a form, I have
<=[Forms]![Switchboard]![RYEndDOS] I have also tried referencing the table <=[Tables]![Reference 03 Data for Forms]![RYEndDOS]

However I recieve error messages when I try either of these. I used this technique successfully a few years ago (Access 97) but cannot duplicate it in Access 2000.

M8KWR (Programmer)
25 Jan 05 10:12
I have tested this within A97, and i got an error message when i was trying to reference the table, but when i referenced a form it worked fine.

All that i can say is to re-check you spelling of your form and field names...

Is the Switchboard form open when you are trying to validate???
TheAceMan1 (Programmer)
25 Jan 05 10:14
How are ya Larry1216 . . . . .

I simulated this with no problem (access 2k).

  1. Is the switchboard open when you enter data is this other form?
  2. Is spelling of names correct?
  3. Post the error you received!

See Ya! .  .  .  .  .  .

Larry1216 (TechnicalUser) (OP)
25 Jan 05 10:52
M8KWR and The ACEMAN1;

Thank you both for responding. I did not have the form open and that made the difference.

Is there a way I can use this type of validation rule without having the or table or form open?

Thanks, Larry1216
TheAceMan1 (Programmer)
25 Jan 05 13:44
Larry1216 . . . . .

Yes . . . you can use the OpenArgs arguement of the DoCmd.OpenForm method.

In the calling method you use to open the form, copy/paste the following code:

CODE

   Dim Build As String
   
   If Trim(Me!RYEndDOS & "") = "" Then
      'No Date message here
   Else
      Build = "<=#" & Me!RYEndDOS & "#"
      DoCmd.OpenForm "frmDates", acNormal, , , , , Build
   End If

Then . . . in the OnOpen event of the opened form, copy/paste the following:

CODE

   Me!DateControlName.ValidationRule = Me.OpenArgs
Thats it . . . give it a whirl & let me know . . .

See Ya! .  .  .  .  .  .

willir (MIS)
25 Jan 05 15:12
If you are referencing other tables (and forms), I have always found it better to reference the data in the table for current data, rather than referencing the form.

For example:

<=Dlookup("[RYEndDOS]", "[Reference 03 Data for Forms]", "YourWhereClause")

Your "where clause" is whatever condition you use to find the specific record.

Richard

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close