Problem with Referencing a Controls Value

G

Gummy

Hello,

I have the following code on a form:


For Each ctr In Forms(strCurrentFormName).Controls

If TypeOf ctr Is TextBox Then
intTxtCount = intTxtCount + 1
Else
textBoxOrigValueArray(intTxtCount) = ctr.Value
ElseIf TypeOf ctr Is ComboBox Then
intTxtCount = intTxtCount + 1
textBoxOrigValueArray(intTxtCount) = ctr.Value
End If
Next

On the networked database this works just fine for me (using Access 2003).
On another computer (Access 2003 - SP1) I get the error on ctr.Value that
the following error:
Run-time error '2447': There is an invalid use of the dot (.) or !
operator or invalid
parentheses.

Why would it work fine on my machine and not her's. Plus we have all the
same references loaded.

Thanks for the help.
 
R

Rob Oldfield

Does it break immediately? If not, then when it does, what type of control
is ctr?
 
G

George Nicholson

this works just fine for me
not unless what you posted has a hell of a typo. ElseIf can't appear after
Else.

I know this is unrelated to your stated problem, but that kind of
impossibility in "code that used to work" makes me wonder how else the
posted code differs from what you are actually having problems with.
 
G

Gummy

Your right., I had some stuff rem'ed out and I tried to clean it up before I
posted it. Sorry I didn't do a good job with that. However, the issue really
is as I stated earlier.
 
G

Gummy

It does break immediately and the control is a text box.

The only thing that seems fairly consistent is if the textbox value is null.
That seems to set it off.

Also, I have a problem with the following:

Dim ctr as Control
Dim varCtrValue as Variant

varCtrValue = ctr.Value
I get the error on this line: Object does not support this method or
property.

Thanks for the help.
 
M

Marshall Barton

I think you missed George's point.

If you want help debugging some code, it helps if we can see
the real code that demonstrates the problem.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top