Field Names as variables ?

kotzo

Board Regular
Joined
Aug 1, 2010
Messages
119
Hi to all,

I want to repeat the following code 15 times, for field names me.c1, me.c2, me.c3,..., me.c15:

Code:
If Me.c1.Enabled = [URL="http://www.mrexcel.com/forum/"]True[IMG]http://cdncache1-a.akamaihd.net/items/it/img/arrow-10x10.png[/IMG][/URL] And (IsNull(Me.m1) = False Or IsNull(Me.d1) = False Or IsNull(Me.a1) = False Or IsNull(Me.q1) = False) Then
Me.m1 = Null: Me.d1 = Null: Me.a1 = Null: Me.q1 = Null
End If


The code should have the following behavior (not a real code, only as an example):

Code:
for y=1 to 15

If Me.("c" & y).Enabled = [URL="http://www.mrexcel.com/forum/#"]TRUE[IMG]http://cdncache1-a.akamaihd.net/items/it/img/arrow-10x10.png[/IMG][/URL] And (IsNull(Me.("m" & y)) = False ............................

End If

next y

How could I do this ?

Thanks for the support.

kotzo
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Are c1, c2, c3... etc actually controls on a form?
 
Upvote 0
Re: [CLOSED] Field Names as variables ?

Try this.
Code:
for y=1 to 15

If Me.Controls("c" & y).Enabled = True And (IsNull(Me.Controls("m" & y)) = False ............................

End If

next y
 
Upvote 0

Forum statistics

Threads
1,221,904
Messages
6,162,743
Members
451,785
Latest member
DanielCorn

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top