clearing fields in a form

  • Thread starter Thread starter samlwendel
  • Start date Start date
S

samlwendel

Guest
I have this form that I build for my work to search for circuit information or customer information. I would like to have a but so I can clear all the fields to I can start a new search with out closing out of the form and reopening it.
Any help that can be given wout be great.
Thanks,
Sam Wendel
 
All you have to do is have some code (probably attached to a command button's On_Click event) that sets the controls to null.

The easiest code is -

If setting a text box:
MyControlName.Value = ""

If setting a combobox:
MyComboBoxName.Value = Null

If setting a checkbox:
MyCheckboxName = Null or you can use
MyCheckBoxName = False to clear the box instead of a null.


BL
hth

[This message has been edited by boblarson (edited 01-28-2002).]
 
Thanks for the help bob I still can't get that to work. Here is a copy of the code of the search button that I have already made to do my search. My textbox name is fratm1.

Private Sub Search1_Click()
On Error GoTo Err_Search1_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "FRM FRAME RELAY"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Search1_Click:
Exit Sub

Err_Search1_Click:
MsgBox Err.Description
Resume Exit_Search1_Click
FRATM1.Value = ""
End Sub

I put the fratm1.value ="" at the end. Is that right???
Again thanks for the help...
 
You have a couple of problems here ........

First you have placed the line in the wrong place. The line will never execute the way you have it because the sub will exit and never get to the line of code. Try using this altered code. Notice where the line has been placed.

Private Sub Search1_Click()
On Error GoTo Err_Search1_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "FRM FRAME RELAY"
DoCmd.OpenForm stDocName, , , stLinkCriteria
FRATM1.Value = ""

Exit_Search1_Click:
Exit Sub

Err_Search1_Click:
MsgBox Err.Description
Resume Exit_Search1_Click

End Sub

The second problem is that you are using "stLinkCriteria" as "Where" argument of the DoCmd.OpenForm method. You have the variable "Declared" properly .... but you are not assigning this variable any value.

RDH
 

Users who are viewing this thread

Back
Top Bottom