Results 1 to 2 of 2

Thread: Sub form only one entry

  1. #1
    Davisricky is offline Senior Member
    Join Date
    Dec 2009
    Posts
    331
    Rep Power
    3

    Default Sub form only one entry

    How to limit sub form to have only one entry?

    I have construct a subform "frm_Obs1" on main form "frm_Main". I would like to write code for following condition.

    1. If there is no record, 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 unusual ways but any of them worked out. Can anybody How to limit subform to have only 1 entry? Any help.
    Last edited by Davisricky; 01-27-2010 at 01:29 PM.

  2. #2
    Garcíarobine is offline Senior Member
    Join Date
    Dec 2009
    Posts
    334
    Rep Power
    3

    Default

    Just try to run following code from the Current () Event of the Main Form but remember that you have to duplicate it in the Current () Event of the Sub-Form. After using this code try to run entire program and make sure whether you are able to add only one record or not.

    Vb 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

    C# code:

    private void Form_Current()
    {
    {
    if ((Me["frm_Obs1"]).Form.Recordset.RecordCount == 0)
    {
    (Me["frm_Obs1"]).Form.AllowAddition = true;
    }
    else {
    (Me["frm_Obs1"]).Form.AllowAddition = false;
    (Me["frm_Obs1"]).Form.AllowEdit = true;
    }
    }
    }

Similar Threads

  1. Expedite data entry
    By terank in forum Web. 2.0
    Replies: 1
    Last Post: 12-19-2009, 07:56 AM
  2. Use panes to simplify data entry
    By qeintine641 in forum Everything Else
    Replies: 0
    Last Post: 03-16-2009, 06:50 AM
  3. Write journal entry on Hi5
    By winstore in forum General Internet Terms
    Replies: 0
    Last Post: 07-14-2008, 06:26 PM
  4. How to automatic entry into Windows XP.
    By techno23 in forum Windows XP
    Replies: 0
    Last Post: 02-11-2008, 12:55 PM
  5. How to automatic entry into Windows XP
    By techno23 in forum Windows XP
    Replies: 0
    Last Post: 02-11-2008, 11:58 AM

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
SEO by SubmitEdge

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48