Results 1 to 8 of 8
  1. #1
    g=2012 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2012
    Posts
    4

    Macro for visible field in subform

    Hello,

    I have a problem.

    I have created a form with a subform.



    When opening the main form I would like to create a macro that is able to set the property visible/not visible for a certain field if a certain condition on another field is satisfied. I Have Office 2010 and with the macro editor I'm not able to make it work.Can you help me out writing the text as in the macro editor?

    Here below the example:

    Main form name: FORM_1
    Subform name: SUBFORM_2

    Subform field: FIELD_ABC
    Subform field: FIELD_123
    Subform field: FIELD_CHECK

    Opening the form FORM_1, the macro must show the field FIELD_ABC and hide the field FIELD_123 only if FIELD_CHECK is equal to "TEXT OK" ...and the macro must hide the field FIELD_ABC and show the field FIELD_123 only if the field FIELD_CHECK is equal to "TEXT WRONG".

    Ps: I would like to use the same macro on a report.


    Thank you!!!


  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Is record allowed to have a value in only one of these two fields? Why two fields and not just one?

    Is the subform in Continuous or Datasheet view? Code to set textbox Visible or Enabled property will affect all instances of the textbox. Check into textbox Conditional Formatting. It allows conditional disabling of control, however, the control will still be visible.

    I think in report would be better to use expression in textbox ControlSource:
    =IIf([FIELD_CHECK]=True,[FIELD_ABC],[FIELD_123])
    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
    g=2012 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2012
    Posts
    4
    The subform is CONTINUOUS.
    The value will be inputed in the correct field (the one that is visible depending on the condition of the MACRO).

    Can you explain better what do you mean by saying " Code to set textbox Visible or Enabled property will affect all instances of the textbox. Check into textbox Conditional Formatting. It allows conditional disabling of control, however, the control will still be visible."
    What do I have to do?

    Thank you very much,

    Giorgio



    Quote Originally Posted by June7 View Post
    Is record allowed to have a value in only one of these two fields? Why two fields and not just one?

    Is the subform in Continuous or Datasheet view? Code to set textbox Visible or Enabled property will affect all instances of the textbox. Check into textbox Conditional Formatting. It allows conditional disabling of control, however, the control will still be visible.

    I think in report would be better to use expression in textbox ControlSource:
    =IIf([FIELD_CHECK]=True,[FIELD_ABC],[FIELD_123])

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Still didn't explain why there are two fields. If record is allowed to have data in only one, then why not just one field?

    Conditional Formatting for textboxes in forms or reports: http://msdn.microsoft.com/en-us/libr.../gg508986.aspx
    The Enable/Disable setting is the little rectangle next to the font color dropdown.

    This is the Access2007 Conditional Formatting manager:
    http://office.microsoft.com/en-us/ac...010208133.aspx
    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
    g=2012 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2012
    Posts
    4
    There are 2 fields because one is NUMBER format, the other one is TEXT format.

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    What does the number field data indicate? Is it really a number entity (used in computations) or an identifier composed of digits?
    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.

  7. #7
    g=2012 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2012
    Posts
    4
    it is a number entity used in computation. Can you please explain step by step how to proceed for the visible/non visible condition?

    thank you,

    Giorgio

  8. #8
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    I am suggesting you try Conditional Formatting on the textbox. The linked articles give step-by-step guidelines on how to use this Access feature. I am not going to repeat them. However, can use Design View instead of Layout View.
    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. Replies: 5
    Last Post: 04-06-2012, 10:59 AM
  2. Visible property in subform columns
    By MDB in forum Forms
    Replies: 3
    Last Post: 09-03-2011, 06:46 PM
  3. Making subform field visible/invisible
    By Snufflz in forum Forms
    Replies: 3
    Last Post: 01-17-2011, 05:30 AM
  4. Replies: 2
    Last Post: 01-06-2011, 04:38 AM
  5. Replies: 10
    Last Post: 12-31-2010, 12:35 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