Referencing all controls in a given form 
Author Message
 Referencing all controls in a given form

My apologies for posting something so trivial, but please can someone end my
confusion?

I'm attempting to survey all the various inputs in the single form
(addressstuff) on my page to see if any have been changed.

FormClean = True
For Each item in document.addressstuff.elements
 If item.value <> item.defaultvalue Then   <<<<< PROBLEM
  FormClean= False
  Exit For
 End If
Next

I get a runtime error "item - illegal assignment" at the marked line.

Thanks  - Mike -



Fri, 07 Feb 2003 03:00:00 GMT  
 Referencing all controls in a given form
Mike,

    First thing you need to do is to make sure that you're working with
objects when using syntax like "For each xx in yy".

    So,

    Set oElements=Document.FormName.Elements
    For Each oElement in oElements

        'Code

    Next

Another thing to watch out for here is that not every form element has a
default value property (a button for example only has name, type and value
properties).  So you would need to add code (maybe Select Case statements)
to check the elements type (radio, checkbox, text, button, submit, reset,
etc etc), and only perform default value checking for appropriate elements.

Luke


Quote:
> My apologies for posting something so trivial, but please can someone end
my
> confusion?

> I'm attempting to survey all the various inputs in the single form
> (addressstuff) on my page to see if any have been changed.

> FormClean = True
> For Each item in document.addressstuff.elements
>  If item.value <> item.defaultvalue Then   <<<<< PROBLEM
>   FormClean= False
>   Exit For
>  End If
> Next

> I get a runtime error "item - illegal assignment" at the marked line.

> Thanks  - Mike -



Fri, 07 Feb 2003 03:00:00 GMT  
 Referencing all controls in a given form

Luke:

Thanks (again). I took your advice and implemented a hybrid approach.
Problem solved.  - Mike -

Quote:

>Mike,

>    First thing you need to do is to make sure that you're working with
>objects when using syntax like "For each xx in yy".

>Another thing to watch out for here is that not every form element has a
>default value property (a button for example only has name, type and value
>properties



>> My apologies for posting something so trivial, but please can someone end
>my
>> confusion?

>> I'm attempting to survey all the various inputs in the single form
>> (addressstuff) on my page to see if any have been changed.

>> FormClean = True
>> For Each item in document.addressstuff.elements
>>  If item.value <> item.defaultvalue Then   <<<<< PROBLEM
>>   FormClean= False
>>   Exit For
>>  End If
>> Next

>> I get a runtime error "item - illegal assignment" at the marked line.



Sun, 09 Feb 2003 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. getting current record in datagrid to give to a detail form as a reference

2. Make a reference to a MDI form with a reference of a MDI child form

3. referencing a control on a caller form from the called form

4. Referencing ActiveX Control within html form tag

5. Referencing object in form in code / Subform reference problem in code

6. 2 recordsets gives Invalid Reference error

7. Why is it giving a nullobject reference error??

8. Please,Can anyone Give a reference or idea?

9. Define Custom Form as the new Default Form for a given Folder

10. Need Form object given only the form name (string)

11. Unload form after minimizing form gives an error!

12. Solution: Unload form after minimizing form gives an error

 

 
Powered by phpBB® Forum Software