Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Clearing TextBox Values

Status
Not open for further replies.

BettyMatz

Technical User
Feb 3, 2003
11
US
I have a form that has 4 ListBoxes that are used to
select criteria for a query. Those 4 ListBoxes are bound to TextBoxes. A command button is used to open a report with that query.

I need to clear those textboxes after the report is opened.

Any suggestions.

Thanks,

Betty
 
Add code similar to

Code:
txtControlNameHere = vbNullString

at the end of the Click event code behind the command button that opens the report. Obviosly you'll need four lines like this, one for each text box. [pc2]
 
If you want to clear ALL of the textboxes on a form...

dim objCTL as Control

For Each objCTL in me.Controls
If objCTL.ControlType = acTextBox Then
objCTL.Value = vbNullString
End If
Next objCTL
 
MP9

I tried that and get a runtime error 2449 with message " you can't assign a value to this object"

Betty
 
Nealy,

Tried your suggestion also and get same error message "Can't assign a value to this object.

Betty
 
Check the properties of the relevant field in the underlying table, specifically the Required property and the Allow Zero Length property. If the field is required or does not allow zero-length then you won't be able to set it to vbNullString. [pc2]
 
NealV: The Text boxes are bound to ListBoxes.

MP9: Changed Required property and Allow Zero length and still get same error.
 
Ok I figured it out. Instead of clearing Textbox, I did ListBox instead. e.g. ListBox1=vbnullstring. that worked.

Thanks for your help.

Betty
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top