Results 1 to 2 of 2
  1. #1
    Vaibhav2015 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2015
    Posts
    14

    How To Validate Textbox Data With Another Table Field

    Hi,



    I have created form and added text box and command buttons.

    I want to cross check the data entered in textbox is valid or not from another table.

    If entered data (request number) is there in table then command button is enabled otherwise it should give message "Request number is invalid.".

    Please advice how I can write VBA code in form. I have try below VBA code but I got error.

    Private Sub Text0_AfterUpdate()
    If Me.Text0 = [ACT_Main_Table]![MDM request no] Then
    Me.command1.SetFocus
    Me.command2.SetFocus

    Else
    MsgBox " Please enter valid MDM request Number", vbCritical

    End If
    End Sub

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    For starters, validation is typically done in the before update event:

    http://www.baldyweb.com/BeforeUpdate.htm

    you can't refer to a table that way. I'd use a DCount().
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Validate characters in textbox before more vba
    By Ruegen in forum Programming
    Replies: 29
    Last Post: 02-13-2014, 04:45 PM
  2. Replies: 4
    Last Post: 12-22-2011, 03:04 AM
  3. Match TEXTBOX value with TABLE and then validate?
    By taimysho0 in forum Programming
    Replies: 2
    Last Post: 11-22-2011, 11:25 AM
  4. Replies: 4
    Last Post: 01-05-2011, 07:56 AM
  5. Validate Form Field based on Duplicate Data
    By bornfattom23 in forum Forms
    Replies: 3
    Last Post: 11-05-2010, 02:02 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