Results 1 to 2 of 2
  1. #1
    mkfloque is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jan 2012

    Conditional Macro in a form (if first box "yes", then 2nd box is enabled)


    I have a form where one field is called "Past Medical History?" & has a yes/no fieldtype.

    Below that , i have a field called "Past Med History Details", a text fieldtype.

    I don't want "Past Med History Details" enabled UNLESS "Past Medical History?" is checked "yes".

    I tried using a conditional macro on the "Past Med History Details" (before update) , with:
    Condition: [Past Med History?]=yes
    Action: SetProperty
    Control Name: (I left blank, since i'm working on the control's property)
    Property: Enabled
    Value: -1 (meaning yes, enable field when condition is met)

    But, "Past Med History Details" is still enabled, even if "Past Medical History" isn't checked "yes."

    Any suggestions?


  2. #2
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    I would use VBA to do this. First, create a procedure that determines whether or not the field shoule be enabled, Something like this:
    Sub FieldEnabling()
        If Me.Past_Medical_History = True Then
            Me.Past_Med_History_Details.Enabled = True
            Me.Past_Med_History_Details.Enabled = False
        End If
    End Sub
    Then, call this code from the "Current" event of the Form (so that is is run every time you open the Form or go to a new record:
    Private Sub Form_Current()
        Call FieldEnabling
    End Sub
    and also call it from the AfterUpdate event of your Yes/No field (so it gets updated if that field changes):
    Private Sub Past_Medical_History_AfterUpdate()
        Call FieldEnabling
    End Sub
    Using Access 2007
    Proficient in Access, Excel, VBA, and SQL

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

Similar Threads

  1. Error Using "Browse To" Macro Command
    By Aaron5714 in forum Access
    Replies: 2
    Last Post: 06-14-2012, 03:01 PM
  2. Replies: 11
    Last Post: 03-29-2012, 02:32 PM
  3. Get "My Documents" in Access 2007 macro
    By RMittelman in forum Programming
    Replies: 7
    Last Post: 10-31-2011, 03:01 PM
  4. Enabled = "No" not working
    By jgelpi16 in forum Forms
    Replies: 3
    Last Post: 07-07-2011, 10:53 AM
  5. Conditional formatting to, "=sum"
    By AZstudent in forum Reports
    Replies: 3
    Last Post: 11-01-2010, 11:54 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