Results 1 to 3 of 3
  1. #1
    DianeG is offline Novice
    Windows XP Access 2007
    Join Date
    Mar 2010
    Posts
    16

    MACRO help please

    I am trying to build a MACRO to lock a field in a subform when a condition is met, but I am not having any luck. I keep getting "Action Failed" window and I have tried changing things everyway I can think of.

  2. #2
    maximus's Avatar
    maximus is offline Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Aug 2009
    Location
    India
    Posts
    931
    I assume you have the following requirement:

    To Lock a control on a subform based on the value of a control on the main form.

    I am attaching a mdb file:

    What have I done:

    In my main form i have a check box when you check it the textbox control on subform aa is locked:

    code used:

    Private Sub Form_Current()
    Select Case Me.Yes
    Case Is = True
    [Table2].Form![aa].Locked = True
    Case Is = False
    [Table2].Form![aa].Locked = False
    End Select

    End Sub

    Private Sub Yes_AfterUpdate()
    Select Case Me.Yes
    Case Is = True
    [Table2].Form![aa].Locked = True
    Case Is = False
    [Table2].Form![aa].Locked = False
    End Select
    End Sub

    the code is used in the AfterUpdate event of the CheckBox and also on the OnCurrent Event of the Form.
    because this ensures that Lock is opened when you want to create a new entry or use the navigation button to navigate to a entry in which the checkbox is unchecked. It also ensures that the field is locked or unlocked depending on the of the Check box when the form opens

    refer to attached mdb file.

    if this solves your problem mark this thread solved

  3. #3
    Datagopherdan is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Dec 2008
    Posts
    220
    Hi Diane,

    I would highly-recommend taking the route that Maximus posted over using built in Macros. Try to get away from using macros, they are very limiting and in my opinion much harder to manage then properly written VBA code.

    Dan
    Access Development

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

Similar Threads

  1. Pausing a Macro
    By Rick West in forum Programming
    Replies: 0
    Last Post: 03-17-2010, 10:29 AM
  2. Get Function to run as a macro
    By randolphoralph in forum Programming
    Replies: 11
    Last Post: 01-24-2010, 12:30 AM
  3. import using Macro
    By johnny1g in forum Import/Export Data
    Replies: 1
    Last Post: 09-15-2009, 04:21 AM
  4. Access Macro
    By Gargen in forum Access
    Replies: 0
    Last Post: 09-14-2009, 09:13 AM
  5. Macro for Indexed Value
    By jversiz in forum Access
    Replies: 0
    Last Post: 10-19-2007, 01:16 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