amberdextrous
MIS
There's a screenshot of one of the forms for my database. I'm having a problem with the "Clear Text" function. I want the user to be able to click that button and clear all 6 of the unbound text boxes, either before or after they execute a search. As of right now, it will clear them if you click it after you hit Search ONLY if your search returned records. If you run the query and no records are returned, the Clear function acts funky. When you press the button, it will not clear them until you actually click in and out of each one of the text boxes. Also, it works if you click the button before you hit Search (like if you're filling out the fields and make a mistake and decide to start over), unless of course the last query you ran returned no results, then you'll have the problem I described above.
Here's my code:
Code:
Option Compare Database
Private Sub ClearButton_Click()
Me.EnterClientNumber = Null
Me.EnterClientName = Null
Me.EnterProjectNumber = Null
Me.EnterProjectDescrip = Null
Me.EnterProjectManager = Null
Me.EnterDiscID = Null
EnterClientNumber.SetFocus
End Sub
Private Sub CloseButton_Click()
On Error GoTo Err_CloseButton_Click
DoCmd.Close
Exit_CloseButton_Click:
Exit Sub
Err_CloseButton_Click:
MsgBox Err.Description
Resume Exit_CloseButton_Click
End Sub
Private Sub SearchButton_Click()
DoCmd.OpenForm "SearchForm", , , , , acDialog
End Sub
Private Sub SearchButton2_Click()
'Filter data based on search criteria
Form_ViewDataForm.RecordSource = "SearchQuery2"
Form_ViewDataForm.Caption = "Search Results"
MsgBox "Results have been filtered."
End Sub
Private Sub ShowAllButton_Click()
Dim LSQL As String
'Display all customers
LSQL = "SELECT Client.[Client ID], Project.[Project ID], Disc.[Disc ID], Client.[Client Description], Project.[Project Description], Project.[Project Manager] FROM (Client INNER JOIN Project ON Client.[Client ID]=Project.[Client ID]) INNER JOIN (Disc INNER JOIN [Project On Disc] ON Disc.[Disc ID]=[Project On Disc].[Disc ID]) ON Project.[Project ID]=[Project On Disc].[Project ID] ORDER BY Client.[Client ID], Project.[Project ID], Disc.[Disc ID]"
Form_ViewDataForm.RecordSource = LSQL
Form_ViewDataForm.Caption = "View all records"
MsgBox ("All records are now displayed.")
End Sub
Private Sub GenerateReportButton_Click()
On Error GoTo Err_GenerateReportButton_Click
Dim stDocName As String
stDocName = "rptSearchResults"
DoCmd.OpenReport stDocName, acPreview
Exit_GenerateReportButton_Click:
Exit Sub
Err_GenerateReportButton_Click:
MsgBox Err.Description
Resume Exit_GenerateReportButton_Click
End Sub
Any suggestions?