PDA

View Full Version : Solved: Rename a Sub-Form



MichaelH
09-30-2005, 04:47 AM
Hi Everyone,

I'm trying (with my limited Access knowledge) to help someone with a bit of VBA in a new project they have created; we're still both novices.

I'm coming across syntax errors when trying to use sub-form names that contain spaces (I never do this but they have!).

It's easy to rename a sub-form, but is there an easy way to update all the references to that sub-form at the same time.

Equally applies to any other such named objects.

Thanks

Michael

chocobochick
09-30-2005, 06:28 AM
Well, the Find/Replace option in the Edit menu can be used to change all VBA code, but you can't easily do that in other MS Access controls. From past experience, Access will actually make some changes automatically if you rename something, but it doesn't change everything and it's difficult to remember what is and isn't affected.

Where exactly are these syntax errors occurring? Do they still occur if you encase the subform name in brackets? (Example: "[My Subform]")

MichaelH
09-30-2005, 07:29 AM
Hi chocobochicken,


This was extending what you helped me with on my last posting, re REQUERY.

I don't have the project to hand, but what was required was a Requery of a Cust ID control on a form called Room Book from a subform called Cust Det.

(Notice all the spaces!).

The code I was trying to use was (if I remember correctly like this:
-------
Dim ctlName as Control

Set ctlname = Forms!Room Book!Cust Id

ctlName.Requery
--------
This gave me a syntax error on the Set statement which didn't arise if the form was called RoomBook; I tried putting "'s around Room Book but still errored.
Thus I thought to rename Room Book to RoomBook to circumvent.

Thanks

Michael

Oh, just noticed you said to use [Room Book]. Is that the syntax I should have used! (without "'s)

chocobochick
09-30-2005, 07:51 AM
Yeah, try this:

Set ctlname = [Forms]![Room Book]![Cust Id]

MichaelH
10-02-2005, 02:13 AM
Cheers Chocobochicken.


Michael