Can't obtain the value from a control

chillwa

New member
Local time
Today, 14:13
Joined
Jun 16, 2008
Messages
7
I need to obtain the value (a long integer) from each control on my form
but one line of code is giving me an error message.

The error message says "Run-time error 2455, You entered an expression that has an invalid reference to the property value"

The line that is giving me the error is:

quantityshipped = ctl.Properties("Value")

----------------------------------------------

Here is part of the code



Dim ctl As Control
Dim frm As Form
Set frm = Forms![frmResults2]

For Each ctl In frm.Controls


If TypeOf ctl Is TextBox Then
If ctl.Value <> "" Then

productname = ctl.Properties("Name")
quantityshipped = ctl.Properties("Value") 'This line does not work and returns an error message

etc.

---------------------------------------------------

The "Name" property above works, but the value property will not work
I even tried coding it

quantityshipped = ctl.value

All of my code works EXCEPT that one line (above)


any help would be appreciated. I need to obtain the long integer value from this control and store it into a variable.
 
I just got it to work.
I moved it inside of my loop and now it works.

I was just about to delete this post.

thanks for the quick reply

I think the problem was that some of my controls were not Integer values (even through my variable type was), so it was throwing off the code, but when I moved it inside of a loop after I made sure the control was an actual long integer, then it worked.
 

Users who are viewing this thread

Back
Top Bottom