Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2005

    Unanswered: Table field validation

    I want to set a rule in my table that restricts the value that the user can input, based on the value of another field. for example, if the field 'Pack' is '1 by 1 the only value the user can input into the field 'split' is 0. If the field 'Pack' is 2 by 1, 3 by 1 (etc), then the user can input any number. I presume the left function will be required somewhere, cheers.
    Last edited by Fuerteventura; 11-25-05 at 08:57.

  2. #2
    Join Date
    Nov 2004
    out on a limb
    Provided Answers: 59
    I don't think you can build this type of sophistication in a JET database. You can if your back end (datastore) is a server, but not in the default data store in Access (JET).

    So you will have to build your validation into a form.

    To do this place some code in your controls on change, on lost focus events. You will need to consider how you intend to handle chnages in packsize which would invalidate exisiting data, eg if the packsize was 4 & the split set to 2, what happend if you change the packsize to 2

    your validation routine should be stored in a fucntion of its own so it can be called from any other event you think appropriate (eg the forms before update, on current)


  3. #3
    Join Date
    Aug 2005
    cheers for that - will have a play with it this afternoon.

  4. #4
    Join Date
    Oct 2005
    Just a wild guess - I have not tested this - but you might be able to use the afterupdate event and the validationrule property. I do not know whether it is a good method but you can try it.

    sub Pack_afterupdate
    Split_validationrule = "YourValidationString"
    Split_validationtext = "YourValidationErrorText"
    end sub

    Make sure the user cannot enter a value in Split before Pack is entered.

    You should probably ad some code to the form_current event to make sure the validation rules are also correct when browsing through the records.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts