Results 1 to 7 of 7
  1. #1
    pervezjan is offline Novice
    Windows XP Access 2003
    Join Date
    Sep 2012
    Posts
    12

    Need Help to validate More than 3 Field in Access 2003 MDB

    Hi
    Thanks in advance for help


    I have a form and I tried to validate the fields. Through Primary Key in Table It is possible but cursor go to the Command button then its validating. I want if I entered 3 fields it must give a message of duplication. The detail is as under
    Table Name Examination
    FormName Exam
    Field Name IDNO, Semistername, Year (Note the IDNO is numeric Field and rest are text)

    Need your help to resolve.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    If you key/index the fields in the table ,access will automatically tell you about the duplcates.

  3. #3
    pervezjan is offline Novice
    Windows XP Access 2003
    Join Date
    Sep 2012
    Posts
    12
    Dear ranman256 Thank you, Please read my question is I already did the Index It is working but its work with command button. I mean that If I put the data in the start in these 3 fields I need a message that "Record is duplicate". In indexing system I have to fill all the fields then message appeared so that I should stop to put further information in the form that the record is duplicate

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,646
    Then you have the indexing set wrong.

    If you want index in table to prevent duplicate combinations of the three fields, then need a compound index set on those three fields.

    Otherwise, use code in form BeforeUpdate event.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    pervezjan is offline Novice
    Windows XP Access 2003
    Join Date
    Sep 2012
    Posts
    12
    Thanks June7
    That is way I am asking how to put codes. This compound index validation is ok. But I have to fill all the field and when I reach on command button to save the record then message of validation is coming. I need that if I fill these 3 field a message should appear immediately.

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,646
    Would need code in AfterUpdate event of each of the controls bound to those fields. Build a procedure behind the form that can be called by each control's event.

    Example with text, date, number fields.

    Sub Validate()
    With Me
    If Not IsNull(.control1name) And Not IsNull(.control2name) And Not IsNull(.control3name) Then
    If DCount("*", "tablename", "field1='" & .control1name & "' And field2=#" & .control2name & "# And field3=" & .control3name) > 0 Then
    MsgBox "Record already exists with this data. Enter different values."
    End If
    End If
    End With
    End Sub
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    pervezjan is offline Novice
    Windows XP Access 2003
    Join Date
    Sep 2012
    Posts
    12
    Thanks a lot
    June7
    Excellent giving me idea of Dcount function
    Great Job Now I will be able to solve my problem soon.

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

Similar Threads

  1. Replies: 3
    Last Post: 06-20-2014, 02:30 PM
  2. Validate Field Containing Date AND Time
    By tndinnc in forum Access
    Replies: 2
    Last Post: 04-25-2013, 11:11 AM
  3. Validate a field
    By tweety in forum Forms
    Replies: 19
    Last Post: 03-29-2013, 04:06 PM
  4. Replies: 1
    Last Post: 09-05-2012, 02:49 PM
  5. using Functions to validate a date field
    By jamin14 in forum Programming
    Replies: 1
    Last Post: 03-18-2010, 12:46 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