Share via

Access Clear Fields In Form Query button Stop Working

Anonymous
2016-10-11T12:35:56+00:00

Currently have a Multiple Field Search Form (Looks @ 3 fields in a query if matches or is Null, txtFiscalYear, cboStoreName, cboItem) that user can use to query and pull data. When user click on a query button on the main form the results show up on a sub-form. In addition, have a Clear Button that clears all the fields for the user to re-enter data to do another query.  Query work command button works, however; when I hit the Clear button (clears all the fields) the query button does not seem to work anymore until I close out and reopen the forms.

Using the following VBA code as an event procedure when clicked. 

Private Sub cmdbtnQuery_Click()

' Query Command Button

Me.subformStoreItemSearch.Requery

End Sub

Private Sub cmdbtnClear_Click()

'When button is clicked clears the field on the main form

Me.txtFiscalYear = ""

Me.cboStoreName = ""

Me.cboItem = ""

Me.txtItemName = ""

Me.cboStoreLocation = ""

Me.txtState = ""

Me.txtCity = ""

'Requery subform

Me.SubfromStoreItemSearch.Requery

Me.subformStoreItemSearch.SetFocus

DoCmd.GoToRecord , , acLast

Me.txtFicalYear.SetFocus

End Sub

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

1 answer

Sort by: Most helpful
  1. ScottGem 68,830 Reputation points Volunteer Moderator
    2016-10-11T13:45:14+00:00

    I think you also need to add:

    Me.Filter = ""

    Me.FilterOn -= True

    to the clear routine

    Was this answer helpful?

    0 comments No comments