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?
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?
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?
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
give you a forms collection like VB
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:
But see that would make sense..... MS would never go for it...VB Code:
Set objForm = All_Your_Forms_Belong_To_Us.Forms("SomeForm(cmd)")
:D
Good luck.
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.