Hi, I am trying to find code that will let me put a command button on a search form. When it is clicked I want the command filter by selection to filter the records. Basically copying the command when you click the button on the toolbar
when you type "DoCmd.RunCommand", after pressing the space bar, a list of members of the group. Another way is to search the object browser by typing accmd to the search box. A list of all members will be displayed.
cheers for that. Im using Access 2003 and that code throws errors. saying can't find. figured it was something to do with setfocus. Anyway code below sorted it!!!
Private Sub cmdFilterSelect_Click()
On Error Goto ErrHandler
Screen.PreviousControl.SetFocus
DoCmd.RunCommand acCmdFilterBySelection
Exit Sub
ErrHandler:
Select Case Err.Number
Case 2046 'Filter not available at moment
MsgBox "Command not available"
Case Else
MsgBox Err.Number & vbCrLf & Err.Description
End Select
End Sub
Hello, i'm trying to get this to work also. I tried the code posted and it throws up an error with both sets of code. I'm using Access 2003. Any idea what i might be doing wrong? I added a command button, went to build event, Code Builder, then pasted the code. I just need to know what i'm doing wrong. Thanks everyone.