Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using the Set command with a counter variable

Status
Not open for further replies.

btrini10

IS-IT--Management
Dec 5, 2006
73
US
Hi,

I am trying to use "Set" to assign a form control but a part of the control name is a counter.
I would like to use the second line of code where "cnt" is the counter in order to get the first line.

Thanks for any help

Set Planned_Datet = Forms!frm_Review_Plan1!Planned_Date1
Set Planned_Datet = Forms!frm_Review_Plan1!Planned_Date & cnt
 
If I have a form with a command button named Command1, this works:

Code:
Dim c As Control
Dim i As Integer

i = 1

Set c = Me.Controls("Command" & i)

Debug.Print c.Name

You can adjust this logic to fit your needs, which would be something like:
[tt]Set Planned_Datet = Forms!frm_Review_Plan1.Controls("Planned_Date" & cnt)
[/tt]

Have fun.

---- Andy

There is a great need for a sarcasm font.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top