Full Version: What is wrong with this form name
UtterAccess Forums > Microsoft® Access > Access Forms
For i = 1 To 10
Select Case i
Case 1: Set f = Forms![fComp]
The computer refuses to recognize fComp which is a real form name.
I've used the square brackets and no brackets.
I've tried Case 1: Set f = Forms!fComp
and Case 1
Set f = Forms!fComp ' and also with the square brackets.
It keeps saying:
Microsoft Access can't find the form 'fComp' referred to in a macro expression
For Visual Basic Code.
What am I doing wrong?
This time?
If you can post your db, I'll take a look at it, as I suspect there may be another problem, but without seeing the whole code and other db objects it's hard to say for certain. For example, if may look like you have a form named fComp, but really it's fComp with a space on the end that you can't see just by looking at the name.
nother very likely possibility (and one that I'd probably bet is happening) is that you're referencing a closed form. If the form is not open (either in normal or deisgn view), then it is not a member of the Forms collection.
You should not need to have a colon following the Case statement. The colon is a leftover from early BASIC versions where you could put multiple lines on to a single line with the colon signifying a new line. While it's still part of the VBA syntax and therefore allowed, IMHO it's poor programming practice. It might be useful to test something out in the immediate window, but otherwise I'm of the opinion that it should be avoided.
Also, since Forms is a collection, another way to reference the form is by using
But, I don't suspect that that'll change anything in your case--if you can post your db, we can probably pinpoint the problem--just let us know where this particular code snippet is, especially if you have lots of objects and code! frown.gif
Yes, it is closed.
I want to open it, do some stuff, and then close it
and then
open the next one, etc.
K.. Thank you, Thank you. I will open it first. uarulez2.gif uarulez2.gif uarulez2.gif
Sure, no problem! Depending on what you're doing,
ill access the form in question even if it's closed. However, the properties you can access via this manner are VERY limited. Basically, you can access the form name, info on permissions, the owner, and the date created and last updated (however, be warned, if you're trying to get the date last updated in Access 2000, there is a known bug and I can point you to the Microsoft KB article on it if that's what you're after).
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.