Results 1 to 7 of 7
  1. #1
    2 Star Lounger
    Join Date
    Aug 2002
    Location
    Minneapolis, MN, Minnesota
    Posts
    162
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Message Box Validation (Access 2000)

    I have a table in which the Primary Key is not an Autonumber and has an input mask of (0000-aaa). The 4 numbers are mandatory and the 3 letters are optional.

    I would like to attach VB code that will search the table for any records that may match the 4 numbers (and 3 letters) when it is entered into the text box field ClientID.

    If it is a match, then a message box should appear saying
    Easy Access

  2. #2
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Message Box Validation (Access 2000)

    Put it in the BeforeUpdate event of the ClientID control.
    Pat <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

  3. #3
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Message Box Validation (Access 2000)

    That's assuming that by "VB" you really meant VBA in Access. VB controls don't have a BeforeUpdate event, but Access controls do.
    Charlotte

  4. #4
    2 Star Lounger
    Join Date
    Aug 2002
    Location
    Minneapolis, MN, Minnesota
    Posts
    162
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Message Box Validation (Access 2000)

    Hey Pat,
    Thanks for the help, much appreciated!
    Easy Access

  5. #5
    2 Star Lounger
    Join Date
    Aug 2002
    Location
    Minneapolis, MN, Minnesota
    Posts
    162
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Message Box Validation (Access 2000)

    Hi Charlotte,
    Yes, I meant VBA in Access. Do you have any suggestions on how I would format my Sub Procedure for something like this?
    Easy Access

  6. #6
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Message Box Validation (Access 2000)

    if dcount("[keyfield]","tbltable","[keyfield] ='" & me![txtkey] &"'") > 0 then
    msgbox("This value is already used etc")
    cancel = true

    I think your key field is a text field so single quotes need to surround the value in the expression above.
    Regards
    John



  7. #7
    2 Star Lounger
    Join Date
    Aug 2002
    Location
    Minneapolis, MN, Minnesota
    Posts
    162
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Message Box Validation (Access 2000)

    Hey John!
    You Da Man! Thanks for the help. It looks that is doing the trick. I REALLY appreciate it. <img src=/S/clapping.gif border=0 alt=clapping width=19 height=23>
    Easy Access

Posting Permissions

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