Results 1 to 11 of 11
  1. #1
    specialvat is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2016
    Posts
    8

    Newbie data entry help

    Hi,


    Sorry if this is an easy question I am not very good with access.I have created a table and a data entry form.
    Example:
    ID Test Date Serial Number
    1 16/02/16 90001234
    2 16/02/16 90002134
    3 16/02/16 90009999
    4 16/02/16 90001234

    The Serial Number is a validate rule Like"9000????" to make sure data is entered correctly.

    Is there any way to check if the serial number is unique.
    If its now unique I want it give a warning but still enter the data.

    Thanks for any help it will be greatly appreciated.

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2013
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    Use the forms Before Update event to check for existing entries, perhaps with DCount() function and criteria. If DCount returns >0 then give warning with message box
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    specialvat is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2016
    Posts
    8
    Hi
    Thanks for the reply,
    Can you give me an example of DCOUNT and how to send a warning

  4. #4
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2013
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    Is the field "Serial Number" defined in the table as Number or Text
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  5. #5
    specialvat is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2016
    Posts
    8
    HI Bob
    ID is auto number.
    Date is a date and time.
    Serial is an 8 digit text string.
    I can change it to a number if needed.

    Thanks

  6. #6
    specialvat is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2016
    Posts
    8
    Hi
    Really struggling with this.
    So far
    =DCOUNT([Serial Number],"Table1",{Serial Number]="???")

    This this look ok?
    I want to use the serial number enter on the data entry sheet for the search how do I do this.
    Also how do I call about a warning after the check.

    Thanks

  7. #7
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2013
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    Something like:
    Code:
    Private Sub Form_BeforeUpdate(Cancel As Integer)    
        If DCount("ID", "YourTableName", "[Serial Number] = '" & Me.[Serial Number] & "'") > 0 Then
          MsgBox "Serial Number already used"
        End If
        
    End Sub
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  8. #8
    specialvat is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2016
    Posts
    8
    Hi Bob,
    Thanks for the great help it works.
    Can you please explain the above code so I can add it to the another number without asking for help again.
    What is "ID"
    Plus Me.[Serial Number] and "'"

    Cheers

  9. #9
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2013
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    Quote Originally Posted by specialvat View Post
    Hi Bob,
    Thanks for the great help it works.
    Can you please explain the above code so I can add it to the another number without asking for help again.
    What is "ID"
    Plus Me.[Serial Number] and "'"

    Cheers
    Glad it worked for you. I'll do my best to explain the syntax but you may be better of using a google search for the DCount() function or looking at the Access help file for a more detailed explanation.

    The DCount() function returns a count of the records in a domain (table/query)

    "ID" is the name of the field to be counted

    "YourTableName" is the domain that has the records to be counted

    "[Serial Number] = '" & Me.[Serial Number] & "'" is the criteria that tells it which matching records are to be counted


    Serial Number is the name of the field in the domain
    Serial Number is the name of the control who's current value is to be equal to Serial Number

    Quotations are required around Serial Number when the Serial Number is a string but not if if a number
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  10. #10
    specialvat is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2016
    Posts
    8
    Hi Bob,
    Thanks for help and your explanation.
    Your have been a great help.

    Regards

  11. #11
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2013
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    Quote Originally Posted by specialvat View Post
    Hi Bob,
    Thanks for help and your explanation.
    Your have been a great help.

    Regards
    Glad to be of some help. thank you for your kind words and appreciation.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

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

Similar Threads

  1. Replies: 4
    Last Post: 12-21-2015, 10:57 PM
  2. Autonumber after inserting data already *newbie*
    By fuecheefang in forum Access
    Replies: 12
    Last Post: 08-27-2015, 06:59 PM
  3. Replies: 7
    Last Post: 03-05-2015, 07:34 AM
  4. Replies: 5
    Last Post: 03-09-2014, 07:16 PM
  5. how to copy last entry data for new entry
    By alexandervj in forum Access
    Replies: 7
    Last Post: 11-13-2013, 02:57 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