I am using a form to sort a report, but I can't seem to get the "clear form" button to work. I used the wizard when I installed the button, using the clear form option under the form option list. What I want to be able to do is clear the information on the drop down combo box in case I want to change the sort order. This is what the code looks like now:
Option Compare Database
Not sure what I'm doing wrong, but I would appreciate some help. Also attached is a picture of what my sort box looks like.
Option Compare Database
Code:
Private Sub close_Click()
On Error GoTo Err_close_Click
DoCmd.close
Exit_close_Click:
Exit Sub
Err_close_Click:
MsgBox Err.Description
Resume Exit_close_Click
End Sub
Private Sub cmdSetSort_Click()
Dim strSQL As String, intCounter As Integer
'Build strSQL String
For intCounter = 1 To 4
If Me("cboSort" & intCounter) <> "" Then
strSQL = strSQL & "[" & Me("cboSort" & intCounter) & "]"
If Me("Chk" & intCounter) = True Then
strSQL = strSQL & " DESC"
End If
strSQL = strSQL & ", "
End If
Next
If strSQL <> "" Then
'Strip Last Comma & Space
strSQL = Left(strSQL, (Len(strSQL) - 2))
'Set the OrderBy property
Reports![rptPersonnel].OrderBy = strSQL
Reports![rptPersonnel].OrderByOn = True
Else
Reports![rptPersonnel].OrderByOn = False
End If
End Sub
Private Sub Form_Open(Cancel As Integer)
' Open the report maximized, in Print Preview
DoCmd.OpenReport "rptPersonnel", acViewPreview
DoCmd.Maximize
End Sub
Private Sub Refresh_Click()
On Error GoTo Err_Refresh_Click
DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70
Exit_Refresh_Click:
Exit Sub
Err_Refresh_Click:
MsgBox Err.Description
Resume Exit_Refresh_Click
End Sub
Comment