Results 1 to 7 of 7
  1. #1
    GraemeG is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Feb 2011
    Posts
    152

    Validation Rule Form AfterUpdate


    Hello,

    I have the following code in order to validate repsonses made on a form.
    It works but flags up regardless of the repsonse. (i.e. None) Which the point of the rule is if "none" is answered then a renew year is not required and visaversa

    Code:
    Private Sub Form_AfterUpdate()
    If Me.[Entrance Doors - Flats (Fire Doors)] <> "None" And Nz(Me.[Entrance Doors - Flats (Renew Year) 20 LE], "") = "" Then
      MsgBox "If an Entrance Door is Selected a Renew Year Must be Entered!"
      [Entrance Doors - Flats (Renew Year) 20 LE].SetFocus
      Cancel = True
      Exit Sub
     End If
    End Sub
    Any help much appreciated.

  2. #2
    jgelpi16 is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544
    Are your text boxes named the same as the fields in the table? If so that needs to be changed. You can cause problems and confusion within VBA. As suggested in other post you may want to assign text box values to a variable first. Should eliminate spaces from text box names if possible as well.

  3. #3
    GraemeG is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Feb 2011
    Posts
    152
    Thanks for repsonse.
    Sorry not sure in terms txt fields same as fields. I just form wizard' a table and dropped them were I needed them, I havent rename anything. They have labels which are unique?
    Text box values to a variable, not sure on this either?

  4. #4
    jgelpi16 is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544
    Select your text box and in the properties of the text box click on the "All" tab. The very first field is the Text Box name and the second field is the Control Source name. These should not be equal and the Text Box name should not have any spaces in it.

  5. #5
    GraemeG is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Feb 2011
    Posts
    152
    Right.

    Yeah there the same. How much will this cause issues?
    Does the VB code look at the txt name? i.e. If I change all the names will I have to change all my written VB?
    As there is many many to change in different databases' also.

    If I can help it I would prefer not to change

  6. #6
    jgelpi16 is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544
    It is hard to say but you should most definitely start the practice from here on out. I would strongly suggest you go back and change them but I understand the time involved in that.

  7. #7
    GraemeG is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Feb 2011
    Posts
    152
    Still cannot get the above code to work.
    Any ideas? help much appreciated

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

Similar Threads

  1. Validation Rule
    By Megan in forum Access
    Replies: 1
    Last Post: 11-05-2010, 09:45 AM
  2. Validation Rule
    By Christopher in forum Forms
    Replies: 15
    Last Post: 04-20-2010, 06:05 AM
  3. Validation Rule
    By robomose in forum Access
    Replies: 1
    Last Post: 09-09-2009, 05:59 AM
  4. Validation Rule
    By smitstev in forum Access
    Replies: 5
    Last Post: 06-30-2009, 09:58 AM
  5. Validation Rule
    By mistaken_myst in forum Database Design
    Replies: 2
    Last Post: 10-29-2007, 02:08 PM

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