English 中文(简体)
Handling no results for docmd.applyfilter
原标题:

I have an Access app where I use search functionality. I have a TextBox and a Search Button on the form, and it does a wildcard search of whatever the user enters in the TextBox, and displays the records in other controls (Text and Combo Boxes).

To achieve this, I am using the DoCmd.ApplyFilter method and I wanted to know if there is a way that I can handle the no results scenario? What it does currently is shows all the display controls as empty, and the ID field says (AutoNumber) as if I was adding a new record.

If it is not possible to handle no results with DoCmd.ApplyFilter, then is there another way to search the records and handle the no results scenario as well?

最佳回答

You can check the recordsetclone to see if there are any records and remove the filter if there are not.

DoCmd.ApplyFilter , "id=5"
If Me.RecordsetClone.RecordCount = 0 Then
    MsgBox "No records"
End If
问题回答

暂无回答




相关问题
Handling no results for docmd.applyfilter

I have an Access app where I use search functionality. I have a TextBox and a Search Button on the form, and it does a wildcard search of whatever the user enters in the TextBox, and displays the ...

Outlook 2007 CommandBarControl.Execute won t work

I recently switched to Outlook 2007 and noticed that my VBA-macros won t work. I use the following code to open a new appointment-item (and fill it automatically). It worked perfect in Outlook 2003, ...

Connecting to Oracle 10g with ODBC from Excel VBA

The following code works. the connection opens fine but recordset.recordCount always returns -1 when there is data in the table. ANd If I try to call any methods/properties on recordset it crashes ...

MS Access: list macro from VBA

I have to deal with a few macros (not VBA) in an inherited Access application. In order to document them, I would like to print or list the actions in those macros, but I am very dissatisfied by ...

热门标签