Results 1 to 4 of 4
  1. #1
    hoodoo's Avatar
    hoodoo is offline Novice
    Windows 8 Access 2013
    Join Date
    Sep 2015
    Posts
    15

    Question Basic Validation

    Hello!



    In short words, there are 2 buildings (faculties) - each has certain amount of floors. The rooms in the first building are numbered X00-X60 (X being the floor number); whereas, in the second it's 1-25 in the first floor, 26-50 in the second and so on.

    In a table I have to register people assigned to different faculties and rooms. So the question is - how do I make such validation rules, that only allow existing room numbers for each faculty to be entered? I need a validation rule or imput mask that, for instance, doesn't allow me to type "189" if an employee is working in the 1st building, but allows only X00-X60 to be typed. The same goes for the second building - how to I make sure that access doesn't allow "23" to be entered in "Room" field, if the floor for the same entry is set to "3"?

    Hope I made this clear,
    Thanks


    ---------------

    Edit1: I figured out what to do with the first building. I made a validation rule for the table "IIf([FacID]=1;[AssRoom] Like "[1-4][0-5][0-9]" Or "260";[AssRoom] Like "[5-9][6-9]?")". But I cannot think of nothing that can be done with the second building. Any help?
    Last edited by hoodoo; 10-07-2015 at 11:31 AM. Reason: update

  2. #2
    JamesDeckert is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Jul 2015
    Location
    Salina, KS
    Posts
    262
    I don't think you'll be able to do this with an input mask or validation.
    It could be done using the lookup wizard where the field references another table that has a comprehensive list of valid rooms, except the building number is not kept with the room number so this probably won't work either.
    It seems like you'll need to check at the form level where the data is being input to look at the building number, then check the room number entered.

  3. #3
    hoodoo's Avatar
    hoodoo is offline Novice
    Windows 8 Access 2013
    Join Date
    Sep 2015
    Posts
    15
    Quote Originally Posted by JamesDeckert View Post
    I don't think you'll be able to do this with an input mask or validation.
    It could be done using the lookup wizard where the field references another table that has a comprehensive list of valid rooms, except the building number is not kept with the room number so this probably won't work either.
    It seems like you'll need to check at the form level where the data is being input to look at the building number, then check the room number entered.
    I'm sure there is a way how to get this done with validation. I've been given a hint that I should use "IIF" for both buildings. I don't know nothing else though.

  4. #4
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2013
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,610
    IMHO the best place for validation is with code in the forms Before Update event.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 06-16-2015, 03:52 AM
  2. Need basic help
    By jaggi in forum Access
    Replies: 8
    Last Post: 12-08-2014, 03:06 AM
  3. basic help
    By garyptaylor in forum Access
    Replies: 3
    Last Post: 05-17-2011, 01:27 PM
  4. Very new to VBA, could use some basic help
    By oregoncrete in forum Programming
    Replies: 13
    Last Post: 03-24-2011, 09:30 AM
  5. Basic Questions
    By jlclark4 in forum Access
    Replies: 6
    Last Post: 12-13-2010, 12:09 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums