Results 1 to 9 of 9
  1. #1
    TDB7942 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    6

    Can a contol's width be conditionally formatted?

    I have a form with an embedded subform which is a continuous form as opposed to a single form. The subform has two fields. One is called DESCRIPTION and is a question posed to the user. The other is called RESULT and is where the user enters their input. I would like to adjust the size of the RESULT field depending on the question that is asked in the DESCRIPTION field. For example, if the question in the description field is "What is your grade?" and the answer will only be A, B, C, etc. then I would like the RESULTS field to be .5" wide for that question. However, if the question in the DESCRIPTION field is "What do you like about this class?" I want the RESULTS field for that record to be 2" wide.

    Is it possible to vary the size of the controls record by record if desired?



    Thanks to anyone who can help!

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,632
    This is changing the control's Width property. The change will be reflected by all records. If the form is in Datasheet view, control Width cannot be influenced by code.
    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
    TDB7942 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    6

    Here is an example of the kind of things I have been trying...

    Option Compare Database

    Private Sub form_load()
    If Description.value = "What is your grade?" Then
    Result.Width = .5
    End If


    End Sub

  4. #4
    TDB7942 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    6
    I have been afraid of that...however the conditional formatting feature in Access does what I would like but is limited to changing things like background color. I was hoping to find a way to use that logic to change a field's size, record by record. Are you saying that just can't happen? thanks

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,632
    That is my experience. Not if multiple records are displayed, as in Continuous or Datasheet view.

    Why is this important? Controls should be sized or allowed to grow (height) to fit the largest possible value.
    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.

  6. #6
    TDB7942 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    6
    Good question. Maybe I should reflect on why I am doing this before deciding it is the best solution. The database actual has nothing to do with grades. That was a simplified example. The real database is a Performance Appraisal tool for HR. It collects performance evaluations on employees. So my specific examples with reference the true nature of the db.

    i have several tables. some of which are employee, titles, and questions. The questions a person is asked depends on their title, or position in the company. 90% of the data collected can be answered as BT (below target), OT (on target) or AT (above target). However, the other 10 source from different sets of pick lists. So, what I am really trying to do is create a form that allows different pick lists to pop up based on the question that is being asked in that record. The sizing of the field was all part of a complicated process I had developed wth multiple subforms, etc. Maybe I am just charging down the wrong path. Let me try to attach an example of the form for you. If I am successful at this, example 1 is a picture of a screen that should reference BT/OT/AT pick lists. They are currently hard coded values. Example 2 is the next screen (a different set of questions for the same person in which every question references a different pick list from different tables. And the comments field on that page should just be a wider field for asthetic purposes.

  7. #7
    TDB7942 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    6
    Click image for larger version. 

Name:	Example2.jpg 
Views:	4 
Size:	55.9 KB 
ID:	8121will try to upload the images in a few minutes, i can see it didn't work. Thank you so much by the way...Click image for larger version. 

Name:	Example1.jpg 
Views:	5 
Size:	77.2 KB 
ID:	8118
    Last edited by TDB7942; 06-15-2012 at 09:04 PM. Reason: adding images....i think

  8. #8
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Quote Originally Posted by TDB7942 View Post
    ...I was hoping to find a way to use that logic to change a field's size, record by record. Are you saying that just can't happen?
    Quote Originally Posted by June7 View Post
    ...The change will be reflected by all records. If the form is in Datasheet view, control Width cannot be influenced by code.
    That's exactly what June7 is saying! In a Datasheet View or Continuous View Form, the formatting of a given Control in one Record is the Formatting of that Control in all Records! Unless...

    ...Unless, the Formatting is something that can be controlled from the Conditional Formatting Menu! And as you've stated, the Width of a Control is not one of those things! Sorry.

    In the spirit of Full Disclosure, you actually can do Formatting, in Datasheet View or Continuous View Forms, using code, but once again, the formatting of a given Control in one Record is reflected in the Formatting of that Control in all Records! To Format on a Record-by-Record basis, in these kids of Forms, you must use Conditional Formatting!

    As often is the case, there is one exception to this rule! If your Formatting involves Locking or Locking/Disabling a Control, you can do this using code in the Form_Current event! That's because Locking or Locking and Disabling a Control does nothing to change the appearance of the Control. As you move from Record to Record, the Control will be Locked/Unlocked as appropriate for that Control on that Record. Actually, the Control will be Locked/Unlocked on all Records, as is appropriate for the Current Record, but since the Control's appearance is not effected, it doesn't matter! Nobody can tell! You'd have to move to another Record to find out, and then that Record's Control would be Formatted as appropriate for that Record!

    Linq ;0)>

  9. #9
    TDB7942 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    6
    Thank you everyone. I had previously solved for this using one subform per question (essentially giving the user the appearance of each of these troublesome records/questions having a different format for input. I just started to question if there was a more efficient way to make it work. Your comments have helped me quite a bit. Thanks.

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

Similar Threads

  1. Wrap text conditionally
    By devcon in forum Reports
    Replies: 6
    Last Post: 06-12-2012, 12:32 AM
  2. Replies: 3
    Last Post: 03-12-2012, 01:23 PM
  3. Conditionally formatting a mm/dd/yyyy*
    By Steve3415 in forum Reports
    Replies: 4
    Last Post: 03-11-2012, 02:36 PM
  4. Conditionally Required Fields
    By HawkGuru in forum Programming
    Replies: 6
    Last Post: 10-03-2011, 05:47 AM
  5. The section width is greater than the page width?
    By Gary_Marshall in forum Reports
    Replies: 2
    Last Post: 11-13-2009, 01:54 PM

Tags for this Thread

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