Using a variable name as a subform name (1 Viewer)

echorley

Registered User.
Local time
Today, 15:36
Joined
Mar 11, 2003
Messages
131
I have an array of subform names that I want to use as part of a line of code that converts numbers to specified letters:

currSubForm(1) = "sbfrm_Commit_Students_Learn"
currSubForm(2) = "sbfrm_Know_Subject_Teach_How 1"
currSubForm(3) = "sbfrm_Know_Subject_Teach_How 2"

Then inside a loop I have the following:

If Forms![Form1]![' & currSubForm(SF)& '].Form!(currCell) = "1" Then Forms![Form1]![' & currSubForm(SF) & '].Form!(currCell) = "S"

The error I receive is the program cannot find " & currSubForm(SF) & ".

Any ideas? Thanks!
 

DCrake

Remembered
Local time
Today, 20:36
Joined
Jun 8, 2005
Messages
8,632
You do not need the single quotation marks in your sql statement.

David
 

echorley

Registered User.
Local time
Today, 15:36
Joined
Mar 11, 2003
Messages
131
I removed the single quotes from around the variable name and that did not work either. Just to reiterate, this is a variable name that I want to use as the actual name of the subform.
 

SOS

Registered Lunatic
Local time
Today, 12:36
Joined
Aug 27, 2008
Messages
3,517
It would be:

If Forms![Form1].Control(currSubForm(SF).Name).Form.Control(currCell) = "1" ...etc.
 

Users who are viewing this thread

Top Bottom