Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2009
    Posts
    8

    Unanswered: Ms-access help required - little urgent

    Hi professionals

    could any one help me pls

    i am building our hrdatabse in access , i am a novice, i want the access to take control of certain records to be entered only certain no of times

    for example

    in a training database

    if a particular empcd that is (999) is entered for the 6th time,
    i expect the access to display the message as only five entries

    in short , there should not be any entry for any empcd for the 6th time in the database

    i am trying to create a control through forms, but it is not working.

    You can mail me the code builder to my email address :

    rbsaiadithiya@gmail.com


    it is very urgent, kindly help me out

    regards
    r sudhakar

  2. #2
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    We don't email answers, we post them here so that others, with similar problems, can benefit.

    The exact syntax for this will depend on whether empcd is defined in your table as a Text field or as a Numeric field.

    For a Text field:
    Code:
    Private Sub EmpCD_AfterUpdate()
     If DCount("EmpCD", "TrainingTableName", "[EmpCD] = '" & Me.EmpCD & "'") = 5 Then
       MsgBox "Only Five(5) Entries are Allowed Per Employee!"
       Me.Undo
     End If
    End Sub
    For a Numbers field:
    Code:
    Private Sub EmpCD_AfterUpdate()
     If DCount("EmpCD", "TrainingTableName", "[EmpCD] = " & Me.EmpCD) = 5 Then
       MsgBox "Only Five(5) Entries are Allowed Per Employee!"
       Me.Undo
     End If
    End Sub
    Just replace TrainingTableName with the actual name of your table that holds the training records.

    Welcome to the forum!
    Last edited by Missinglinq; 11-06-09 at 12:44.
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  3. #3
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    If it is truly urgent, hire a consultant!
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  4. #4
    Join Date
    Nov 2009
    Posts
    8
    Tks for your timely co-operation

    regards
    rbsai


    Quote Originally Posted by missinglinq View Post
    we don't email answers, we post them here so that others, with similar problems, can benefit.

    The exact syntax for this will depend on whether empcd is defined in your table as a text field or as a numeric field.

    For a text field:
    Code:
    private sub empcd_afterupdate()
     if dcount("empcd", "trainingtablename", "[empcd] = '" & me.empcd & "'") = 5 then
       msgbox "only five(5) entries are allowed per employee!"
       me.undo
     end if
    end sub
    for a numbers field:
    Code:
    private sub empcd_afterupdate()
     if dcount("empcd", "trainingtablename", "[empcd] = " & me.empcd) = 5 then
       msgbox "only five(5) entries are allowed per employee!"
       me.undo
     end if
    end sub
    just replace trainingtablename with the actual name of your table that holds the training records.

    Welcome to the forum!

Posting Permissions

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