Results 1 to 6 of 6
  1. #1
    bcox9 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Dec 2011
    Posts
    10

    Locking individual subform controls in access 2003

    Hi,



    I need the syntax for locking individual subform controls so that the user can only change 3 of the 9 fields in the subforms datasheet view.

    I've tried

    Forms![Formname].[Subformname].Form.[controlname].locked = True

    and it didn't work.

    Let me know if you need any information as to what I'm actually working on.

    Oh and I'll need a 2003 front end, and a 2007-10 front end. So if the syntax is different in the coding, then by all means post both versions.

    Thanks,
    Ben

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    Try referring to the subform container instead. Give the container a name different from the form it holds, like: ctrSubformname. Then:
    Me.ctrSubformname.Form.controlname.Locked = True

    Syntax same for 2003 and 2007-10.
    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
    bcox9 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Dec 2011
    Posts
    10
    Ok did this, and this syntax has to be wrong, because I type

    Me.[ctrDimension_Search_Subform].Form

    and when I put another period, my controls for the subform don't show up in the list of things that are valid arguments.

    I don't know, from all the research I've done online it seems that this is the correct way to lock subform controls, but I can't get it to work.

    Perhaps someone could post a short little subroutine from top to bottom of an example of locking or just manipulating subform controls, when the subform is in datasheet view (not sure if this matters), and it's inside a form.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    Yes, the intellisense popup does not quite work for this syntax. The dot after Form should show list of Form properties/methods but not controls. Typing dot after the control name will not popup anything. You just have to know ahead of time what to type. If you get syntax correct, ignoring upper/lower case, should see the case fix itself to match after press enter for that line.

    I have not referred to subform controls to lock or enable but have referred to them for other properties, such as the value in a textbox. Example:
    If IsNull(Me.ctrFASB.Form.tbxThk1) Then
    CurrentDb.Execute "DELETE FROM FoamedAsphaltSB WHERE LabNum='" & Me.cbxLabNum & "'"
    End If

    and this syntax will act the same way: Me.ctrSections.Form.Controls("tbxSectionID").SelSt art = 4

    I just did quick test with Datasheet and Continuous View forms for the Locked and Enabled properties and it works.
    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.

  5. #5
    bcox9 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Dec 2011
    Posts
    10
    Thanks for the info!

    I decided to take a different approach to my problem. Instead of having a subform I made one form, that is bound to my query, and then set each control = to the equivalent query field.

    I locked all the textboxes except the ones I needed (through properties pane), and the SKU textbox will be used for searching, but doesn't need to be modified so I just pointed my query criteria to that unbound SKU textbox. And since it is unbound no matter if they enter data into it or not, it won't be stored in the table.

    I'm happy to finally get this project done.

    Thanks for all your help!

    One final question that's been bothering me. If you look at a subform in datasheet view it obviously shows in datasheet view. Well the same subform in form view shows you textboxes and lables that correlate with your fields in datasheet view. If you modify the properties of those textboxes in form view do those modifications directly affect the subform fields in datasheet view?

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    I will say yes, just to play it safe, it is possible that changes done in Form view could be saved and impact any view mode.

    I do editing only in Design view. If I use code to change properties during runtime (such as disable a button under some circumstances) then in code that closes the form I use acSaveNo parameter to assure that changes are not saved:
    DoCmd.Close acForm, Me.Name, acSaveNo

    I normally disable the X close button on all forms and control closing form with command button click event.
    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.

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

Similar Threads

  1. locking data in subform after record save
    By Nixx1401 in forum Forms
    Replies: 24
    Last Post: 05-31-2011, 01:48 PM
  2. Replies: 3
    Last Post: 01-25-2011, 09:50 AM
  3. Access 2003 subform linking problem
    By RANCHLAW56 in forum Access
    Replies: 1
    Last Post: 12-26-2010, 05:35 PM
  4. Replies: 1
    Last Post: 11-25-2010, 11:00 AM
  5. Locking Records in Subform
    By MuskokaMad in forum Forms
    Replies: 1
    Last Post: 04-02-2010, 06:34 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