Results 1 to 6 of 6
  1. #1
    kamathmanoj is offline Advanced Beginner
    Windows 10 Access 2013 64bit
    Join Date
    May 2019
    Posts
    41

    Using the Width variable

    Hi Everyone,



    i have a backend Access database which has the field named WIDTH. I created a form that has the control set to this field.
    My issue is that when I try to use Me.Width (caps or otherwise), its returning the width of the form instead of the number entered in that field.

    How do i get around this?

    Regards,
    manoj

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,926
    Width is a reserved word (it is a property). Best to rename the field.

    However, try enclosing in [ ] - Me.[Width]

    Or name control different from field, such as tbxWidth and refer to control bound to field.

    Or try Me!Width. The bang (!) will see field, not property.

    Access is not case sensitive by default.
    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
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,800
    I created a form that has the control set to this field
    Then regarless of spelling or anything else, Me represents the form. You can't use ME to refer to a control on your form.
    Me.ControlNameHere.Width = [Width]

    suggest you avoid using reserved words
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,926
    @Micron, I expect OP was trying an expression like your example so Me.[Width] is certainly acceptable if Width was name assigned to control.
    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
    kamathmanoj is offline Advanced Beginner
    Windows 10 Access 2013 64bit
    Join Date
    May 2019
    Posts
    41
    Thank You. I referred to the name assigned to the control. I was trying to do two things:
    1. Color the control red/green based on the value in the control
    2. Pass the value in the text box to a global variable for use elsewhere.

    Both things worked! This forum is the best! Thanks for sharing the workaround June7 & Micron.

    Micron - I couldn't actually change anything in the table or the remaining database as it is complex and has many forms, queries and reports running that reference that one variable and half of them I could not even find if I tried hard enough.
    I am not exaggerating - there are over 1000 tables, 100+ reports, countless queries and about 800 forms. Its is a fully functional ERP system loaded onto Access.

    Regards,
    Manny

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,926
    You are using VBA to color control? Why not Conditional Formatting?
    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: 9
    Last Post: 06-11-2019, 02:30 PM
  2. Replies: 3
    Last Post: 04-10-2015, 02:35 PM
  3. Replies: 2
    Last Post: 06-28-2014, 01:16 PM
  4. Section Width is greater than page width
    By snowboarder234 in forum Reports
    Replies: 3
    Last Post: 07-31-2013, 09:06 PM
  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

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