Refresh or Requery form

Blkblts

Registered User.
Local time
Today, 09:22
Joined
Jan 21, 2000
Messages
61
I have a form that some information is written to tables the form is not based on. (So I have VB code opening the table and populting using the With statment)
This all works fine until the user wants to add another record to a new member without closing the form. I have a SAVE button the user clicks on but the fields still containe the information in them from the previous, unless I close the form and re-open it. I have tried requery, but it doesn't clear these fields. Am I going to have to set each of these fields to " "? i sure hope not.

kim
 
You will have to set each control to " " as you said.

If you have a lot of controls you can use something like:

Dim Ctl as Control

For Each Ctl In me.Controls
If Ctl.Type = TextBox then
Ctl.Value = ""
End if
Next Ctl

You can add other if statements to handle other control types you may have.

You would put this in your Save button Click event code.

ntp
 
Thanks so much ..I had to tweek the code a little, but it is much better then having to go through each box on the form.

I had to tweek the following line to get it to work....

If Ctl.ControlType = acTextBox Then

Kim
 
FYI
You could also have said:

If TypeOf Ctl is TextBox then...
 

Users who are viewing this thread

Back
Top Bottom