|
-
Dec 23rd, 2002, 11:10 AM
#1
Thread Starter
Fanatic Member
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.
-
Dec 23rd, 2002, 11:32 AM
#2
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?
-
Dec 23rd, 2002, 11:44 AM
#3
Thread Starter
Fanatic Member
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
-
Dec 23rd, 2002, 11:44 AM
#4
Thread Starter
Fanatic Member
Access does...
give you a forms collection like VB
-
Dec 23rd, 2002, 11:56 AM
#5
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:
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.
-
Dec 23rd, 2002, 12:09 PM
#6
Thread Starter
Fanatic Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|