Results 1 to 5 of 5
  1. #1
    zippy483 is offline Novice
    Windows 7 Access 2003
    Join Date
    Feb 2010
    Posts
    26

    Dealing with controls with spaces in their names

    Good afternoon all

    I've inherited an Access dB and have been asked to write some code etc to perform a few relatively simple tasks, the problem is the previous dB owner hasn't used any sort of Naming convention and consequently all the controls and forms etc have spaces in there names I've done some digging around and it seems the solutions I thought I'd found downt work

    I'm using the following line of code to open the Form called My Form



    DoCmd.OpenForm "MyForm", acNormal, , acFormAdd

    Now obviously this only works if I rename the form from My Form to MyForm

    Ive tried replacing the space with an Underscore or surrounding the form name as such [My Form]

    Any ideas, I'll get onto the remainder once I've got a solution to this

    Many Thanks

    Zippy483

  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,820
    That is one case where the space will not impact the code execution. Use "My Form".
    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
    zippy483 is offline Novice
    Windows 7 Access 2003
    Join Date
    Feb 2010
    Posts
    26
    Many thanks June7 that appears to work why I didn't try just that is beyond me

    Now maybe you have some Idea as to how to handle this

    I'm trying to set the properties of a text box on the form I have just opened as above

    the text box is named "Callout record.InHours" , I have attempted to use the follwing line of code to hide the box but I get an error message

    Forms![My Form].Controls!Calloutrecord.InHours.Visible = False

    Any Ideas

  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,820
    Don't think you need .Controls.

    In other situations where names include spaces or special characters/punctuation (underscore is exception) or are reserved words, enclose in [].

    Forms![My Form].[Callout record.InHours].Visible = False

    I always give controls a name different from the field or object they are bound to, like: tbxInHours, then code:

    Forms![My Form].tbxInHours.Visible = False

    If this code is behind the form the control is on can use:

    Me.tbxInHours.Visible = False
    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
    zippy483 is offline Novice
    Windows 7 Access 2003
    Join Date
    Feb 2010
    Posts
    26
    Yep that worked a treat once I'd got my fat fingers around the keyboard without spelling mistakes

    Very much appreciated June

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

Similar Threads

  1. Help - Query Dealing with Dates!!
    By bbanks2 in forum Queries
    Replies: 3
    Last Post: 12-18-2012, 11:31 AM
  2. Help dealing with duplicate records
    By jswenson3 in forum Access
    Replies: 12
    Last Post: 02-01-2012, 10:17 AM
  3. Query Entity Names, and Column Names
    By Accidental DBA in forum Queries
    Replies: 1
    Last Post: 07-22-2011, 02:38 PM
  4. Replies: 5
    Last Post: 04-24-2011, 03:14 AM
  5. Having trouble dealing with these textboxes
    By blacksaibot in forum Programming
    Replies: 2
    Last Post: 04-28-2010, 12:10 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