Results 1 to 6 of 6

Thread: Resolved=>How do I set an object on a form, when the form name has "("and")"

  1. #1

    Thread Starter
    Fanatic Member Avatarp's Avatar
    Join Date
    Sep 2002
    Location
    Calgary
    Posts
    826

    Question Resolved=>How do I set an object on a form, when the form name has "("and")"

    In MS Access, I have a form with a combobox. The form name is "Invoices(Cnd)". How do I set the value of this combobox in vba code?
    Last edited by Avatarp; Dec 23rd, 2002 at 12:10 PM.

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687
    Does Access give you a Forms collection, like VB does? If so, you could loop through that until you find objForm.Name = "Invoices(Cnd)" then use the objForm reference to get to the combo box.
    Just Out of Curiosity: Why/How did the form get THAT name?
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    Fanatic Member Avatarp's Avatar
    Join Date
    Sep 2002
    Location
    Calgary
    Posts
    826

    Company Data!

    When this database was built by my boss, he decided that putting brackets in form and report names was ok. Our database has at least 100 forms and reports with "(" and ")" characters in them. This database is now residing on our clients hard-drives as it is packaged with our total software package we sell.

    I would love to change the database to the way I would do it but the task is monumental. lol

    I thought about the solution you gave me and I know that could work. I feared it would be a search in a for...each...loop. Unfortunate for me. Not very efficient eh!

    Thanks for the help techgnome

  4. #4

    Thread Starter
    Fanatic Member Avatarp's Avatar
    Join Date
    Sep 2002
    Location
    Calgary
    Posts
    826

    Access does...

    give you a forms collection like VB

  5. #5
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687
    See..... this is why development should be left to us professionals..... It was the only solution I could think of (sorry), since the moment you try to access it otherwise, it will think it's a control (form??) array. Too bad there is a way to access it like so:
    VB Code:
    1. Set objForm = All_Your_Forms_Belong_To_Us.Forms("SomeForm(cmd)")
    But see that would make sense..... MS would never go for it...

    Good luck.
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  6. #6

    Thread Starter
    Fanatic Member Avatarp's Avatar
    Join Date
    Sep 2002
    Location
    Calgary
    Posts
    826

    Well well well

    Looks like I can omit the form name when setting an object. I guess VBA for Access recgonizes a variable name to be a form object if the variable name is exactly as the object name.

    My good programming habits include typing the form name when editting form objects. But if I omit the form name it will work! Nice but scary. Another thing to watch out for when naming a variables when working in Access lol.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width