deleting the controlsource for textboxes

G

Guest

Hello,
I have a form with 230 textboxes wich I use to collect data from a questionnaire.
Now i need to make changes to this form. I don't want to store data from the 230 textboxes but to calculate data from them and store the result.
So i need to delete the controlsource for those textboxes.
To make things easier, I have created on the form a command button with this code
Private Sub Command485_Click()
Dim quale As Integer
Dim nomino As String
For quale = 1 To 270
nomino = "i" & quale
Me.Controls(nomino).ControlSource = ""
Next quale
DoCmd.Close acForm, Me.Name, acSaveYes
End Sub

This way I was suppose to clean the controlsource property for all the controls I intended to clean.

It doesn't work, obviously.

I have tried also:

Private Sub Command485_Click()
Dim ctl As control

For each ctl in me.controls
if ctl.controltype=actextbox then
ctl.ControlSource = ""
end if
Next quale
DoCmd.Close acForm, Me.Name, acSaveYes
End Sub

still not working.
What is wrong?
Thanks...
Rocco
 
C

Chris Nebinger

Add this to a module, not behind a form...



Sub DeleteControlSource()
Dim frm As Form
DoCmd.OpenForm "form1", acDesign
Set frm = Forms("Form1")
dim i as integer
for i = 1 to 270
frm.Controls("i" & i).ControlSource = ""
next i
DoCmd.Close acForm, "form1", acSaveYes
End Sub
-----Original Message-----
Hello,
I have a form with 230 textboxes wich I use to collect data from a questionnaire.
Now i need to make changes to this form. I don't want to
store data from the 230 textboxes but to calculate data
from them and store the result.
So i need to delete the controlsource for those textboxes.
To make things easier, I have created on the form a command button with this code
Private Sub Command485_Click()
Dim quale As Integer
Dim nomino As String
For quale = 1 To 270
nomino = "i" & quale
Me.Controls(nomino).ControlSource = ""
Next quale
DoCmd.Close acForm, Me.Name, acSaveYes
End Sub

This way I was suppose to clean the controlsource
property for all the controls I intended to clean.
 

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