Results 1 to 10 of 10
  1. #1
    Freddie81 is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Mar 2018
    Posts
    149

    Ho can I limit the amount of records in a table to one

    Hi Guys

    Ive got a table for Company details called CompanyF that the user can enter info about their company or business. This info will be used on the forms and reports. I however want them to be able to enter ONE record and no more. How can I get this to work? I noticed that if I used the Enter key to run through fields on my frm it automatically creates a econd record after the last field is completed and Enter is pressed. How can I stop this and only allow one record?

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,820
    Set form Cycle property to CurrentRecord.

    Why would record be created just by moving to New Record row? Is there any code that populates a field?

    Code behind button to open form. Code checks if record exists, if it does then open form to that record, if not then open form to New Record.


    Don't allow users to interact with tables and queries, just forms and reports. Manage this with a lot of code and database settings.
    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.

  3. #3
    Freddie81 is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Mar 2018
    Posts
    149
    Hi again June7

    Thank you, ill lok for the cycleRecord property as suggested.

    I dont allow users access to the tables and queries. I use forms or user input.

    Version one of the program is basically finished now...just small little things left then V2 strts LOL

  4. #4
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,016
    Something like this, perhaps:

    Code:
    Private Sub Form_Current()
     If DCount("*", "CompanyF") > 0 Then
      Me.AllowAdditions = False
     Else
      Me.AllowAdditions = True
     End If
    End Sub

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  5. #5
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    Deleted .. My comment was wrong.
    Last edited by isladogs; 05-13-2018 at 06:38 AM. Reason: Incorrect post
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  6. #6
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,016
    Yes...yes it was! But that's OK...because I love Black Labs!

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  7. #7
    Freddie81 is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Mar 2018
    Posts
    149
    Thank you Missinglinq , I changed the CompanyF to CompanyT and works perfectly.

  8. #8
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,016
    Quote Originally Posted by Freddie81 View Post

    Ive got a table for Company details called CompanyF
    So that was a typo?

    Glad we could help!

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  9. #9
    Freddie81 is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Mar 2018
    Posts
    149
    Lol...yes it was..Sorry my friend.

  10. #10
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    Quote Originally Posted by Missinglinq View Post
    Yes...yes it was! But that's OK...because I love Black Labs!

    Linq ;0)>
    That's the problem with instant notification emails....no time to retract nonsense before it goes out to the world
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

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

Similar Threads

  1. Replies: 6
    Last Post: 04-27-2018, 10:39 AM
  2. Replies: 5
    Last Post: 09-21-2015, 10:52 AM
  3. Replies: 2
    Last Post: 05-25-2015, 05:02 AM
  4. limiting amount of records
    By yaro.kobzar in forum Programming
    Replies: 1
    Last Post: 05-17-2011, 07:01 PM
  5. Replies: 5
    Last Post: 05-14-2011, 04:31 AM

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