K
Kevin Hughes
Greetings all:
Having an issue with updating a long list of properties through code. When
done, this form is going to have about 80 command buttons, where the
captions for each are going to be supplied from fields in a database where
each of a few hundred users have customized the records, so obviously I must
do a dynamic update for each one.
Trouble is, I can't seem to figure out how to address the property to
update. I have a string expression that evaluates to the property name, but
Access has defied all my efforts to change the property's value. I've set
individual properties through code before, but how does one use a string to
represent the property name, so that one can update multiple properties
through a loop??
Here's the code stub I'm working with, just wanted to get it to change the
caption on 20 command buttons to the numbers 1-20 for now, the rest of the
code I'll be fine with:
Private Sub Form_Open(Cancel As Integer)
Dim strcount As String
Dim str1 As String
Dim str2 As String
Dim str3 As String
For x = 1 To 20
str1 = "Forms!Form1!Command"
str2 = Trim(Str(x))
str3 = ".Caption"
strcount = str1 + str2 + str3
MsgBox (strcount) <== this expression is correct
Eval(strcount) = (Str(x)) <== assignment fails
Next x
End Sub
This is in 2K, but I need a 97 answer as well, some customers won't/don't
change or update.
Thanks in advance for rescuing an infrequent programmer from one of access'
lovely quirks:
Kevin
Having an issue with updating a long list of properties through code. When
done, this form is going to have about 80 command buttons, where the
captions for each are going to be supplied from fields in a database where
each of a few hundred users have customized the records, so obviously I must
do a dynamic update for each one.
Trouble is, I can't seem to figure out how to address the property to
update. I have a string expression that evaluates to the property name, but
Access has defied all my efforts to change the property's value. I've set
individual properties through code before, but how does one use a string to
represent the property name, so that one can update multiple properties
through a loop??
Here's the code stub I'm working with, just wanted to get it to change the
caption on 20 command buttons to the numbers 1-20 for now, the rest of the
code I'll be fine with:
Private Sub Form_Open(Cancel As Integer)
Dim strcount As String
Dim str1 As String
Dim str2 As String
Dim str3 As String
For x = 1 To 20
str1 = "Forms!Form1!Command"
str2 = Trim(Str(x))
str3 = ".Caption"
strcount = str1 + str2 + str3
MsgBox (strcount) <== this expression is correct
Eval(strcount) = (Str(x)) <== assignment fails
Next x
End Sub
This is in 2K, but I need a 97 answer as well, some customers won't/don't
change or update.
Thanks in advance for rescuing an infrequent programmer from one of access'
lovely quirks:
Kevin