Results 1 to 2 of 2
  1. #1
    LanieB is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Nov 2011
    Posts
    54

    Lightbulb Lock subform to only allow one record entry

    Hello all!

    I have a subform that I want to lock so it can only allow one record entry. Example -- This database is used for internal file audits -- There is a table with all the file information -- A table with all the audit information.

    The Main Form is the file information -- the subform is the audit information for that particular file.

    There won't be two audits on one file, so I want that subform to only allow one entry. How can I force it to only allow one record?

    Please let me know if you need any further information! Thank you!

  2. #2
    ketbdnetbp is offline Competent Performer
    Windows 7 32bit Access 2003
    Join Date
    Mar 2011
    Location
    Midwest
    Posts
    254
    LanieB -

    There are several ways of accomplishing this task. One way (untested) would be to try something like:

    dim x as Integer
    x = [Forms]![MainFormName]![SubformName].Form.RecordsetClone.RecordCount
    If x >= 1 then
    [Forms]![MainFormName]![SubformName].Enabled = False
    else
    [Forms]![MainFormName]![SubformName].Enabled = True
    End if

    in the current event of the main form. Then, in the beforeupdate event of the subform, you may need to add:

    dim z as Integer
    [Forms]![MainFormName]![SubformName].Form.RecordsetClone.MoveLast
    z = [Forms]![MainFormName]![SubformName].Form.RecordsetClone.RecordCount
    If z < 2 then
    exit sub
    else
    MsgBox "Only one audit record is allowed"
    Cancel = True
    end if

    Hope this gets you started,

    Jim

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

Similar Threads

  1. Lock control after data entry
    By Scott_80 in forum Programming
    Replies: 12
    Last Post: 01-07-2015, 03:35 PM
  2. Replies: 9
    Last Post: 09-13-2012, 05:18 PM
  3. Replies: 9
    Last Post: 05-12-2012, 12:16 PM
  4. lock a record
    By Nokia N93 in forum Programming
    Replies: 3
    Last Post: 02-21-2011, 02:51 PM
  5. Replies: 4
    Last Post: 01-23-2011, 09:01 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