I have a userform with 10 nearly identical fields: txtId1, txtId2 ..... txtId10
I want to retreive the fieldvalue if one is entered.
I can do this by:
x = 0
If frm.txtId1.value <> "" Then
Redim preserve ids(x) = frm.txtId1.value
x = x =1
End if
If frm.txtId2.value <> "" Then
Redim preserve ids(x) = frm.txtId2.value
x = x =1
End if
But that is not what I want, I'm lazy and I want to write as little as possible code
So I thought of
For x = 1 to 10
field = "txtId" & x
Redim preserve ids(x-1) = frm.Getvalue(field)
Next x
What is correct for the bold code? This option doesn't work also frm.field.value doesn't work.
Thank you.
Bookmarks