Results 1 to 5 of 5

Thread: How to limit subform to have only 1 entry?

  1. #1
    Join Date
    Aug 2009
    Posts
    51

    How to limit subform to have only 1 entry?

    Hello to all,
    I am new to this forum. In my project I have created a subform "frm_Obs1" on main form "frm_Main". I want to write code for following condition.
    1. If there is no records, I want the other user to be able to add one.
    2. If there all ready is one, I want the user to be able to change it, but not add anymore. I tried various method but none of them worked out. Can anyone How to limit subform to have only 1 entry? please help me.

  2. #2
    Join Date
    Nov 2005
    Posts
    1,323

    Re: How to limit subform to have only 1 entry?

    Hi I have just written following code for doing all things that you are want to do. Just try to run following code from the Current() Event of the Main Form but keep it mind that you have to duplicate it in the Current() Event of the Sub-Form. After using this code try to run hole program and check whether you are able to add only one record or not.

    Code:
        Private Sub Form_Current()
       With Me![frm_Obs1].Form
          If .Recordset.RecordCount = 0 Then
            .AllowAddition = True
         Else
          .AllowAddition = False
           .AllowEdit = True
          End If
     End With
      End Sub

  3. #3
    Join Date
    Oct 2005
    Posts
    2,393

    Re: How to limit subform to have only 1 entry?

    There is another way to limit subform to have only 1 entry. First make sure that record of subform is inserted when the record of main form is inserted. It is for no hassle after wards with "Allowadditions" class. Because by doing this we will ensure that every record is there. You can also use default field like "<Enter new data>" to show the user that this field is not filled yet.

  4. #4
    Join Date
    May 2008
    Posts
    2,389

    Re: How to limit subform to have only 1 entry?

    Hey it is very easy process. You there is no need to use 1:1 ratio for solving above program. You have to use 1:?, where ? -> 0 or 1 code to solve above program. There is no need to have record association with any field. Make sure that record will not be exceed than single record. Just try above code in your suForm and try to run program.

  5. #5
    Join Date
    Jan 2008
    Posts
    1,521

    Re: How to limit subform to have only 1 entry?

    You have to create separate table with built on a 1:1 basis for storing such items as fit within a particular area. Just create separate 1:1 table to store above information without losing anything with regarding to normalization. After this make proper connection in your computer and then try to run that code and test whether you get the same problem or not.

Similar Threads

  1. Not able to have split form in a subform?
    By Quattro in forum Windows Software
    Replies: 4
    Last Post: 02-09-2009, 06:50 PM
  2. Access 2007 subform not refresh
    By avvia in forum Windows Software
    Replies: 2
    Last Post: 13-07-2009, 11:49 AM
  3. MS Access - How to filter subform
    By Zariah in forum Windows Software
    Replies: 3
    Last Post: 05-06-2009, 05:27 PM
  4. Form SubForm ACCESS 2007
    By streetprods in forum Software Development
    Replies: 2
    Last Post: 30-05-2009, 03:18 PM
  5. Requery of subform in MS access 2007
    By Computer_Freak in forum Tips & Tweaks
    Replies: 1
    Last Post: 16-05-2009, 09:56 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,715,529,455.81510 seconds with 17 queries