resetting fields thru code

  • Thread starter Thread starter SF
  • Start date Start date
S

SF

Hi,

I put a button on an unbound form to reset several unbound fields to null.

The code below give me an error "Method or data member not found"

Dim ctl As Control

For Each ctl In Me.Controls
If ctl.ControlType = acTextBox Then
Me.ctl = ""
End If

Next ctl

SF
 
In the loop you need:
ctl = Null

Me.ctl would expect a control literally named "ctl". Your ctl variable is
already a reference to the text box.

Also note that there is a very big difference between Null and a zero-length
string. see:
Nulls: Do I need them?
at:'
http://allenbrowne.com/casu-11.html

There are other conditions where your code could fail as well, e.g. a text
box bound to an expression such as:
=Date()
 
Back
Top