coasterman
Registered User.
- Local time
- Today, 06:50
- Joined
- Oct 1, 2012
- Messages
- 59
I have a form which filters records by a number of different query. The query is selected from a combo box on the main form and this works fine.
What I would like to do is prevent the recordsource from being changed to a query where there are no matched records.
I've being playing with some code but am not getting to far.
Private Sub cboQueryPicker_AfterUpdate()
I suspect the method isn't supported. I'm not at all familiar with DAO but would that be the way to do it?
What I would like to do is prevent the recordsource from being changed to a query where there are no matched records.
I've being playing with some code but am not getting to far.
Private Sub cboQueryPicker_AfterUpdate()
Code:
Dim myquery As String
On Error GoTo Errorhandler
myquery = Me.cboQueryPicker.Column(1)
Me.RecordSource = myquery
If Not RecordCount > 0 Then
MsgBox "No records to display"
End If
Exit_Point:
Exit Sub
'If user cancels the paramater search then exit the sub at the Exit_Point: above
Errorhandler:
Select Case Err.Number
Case 2001, 2501 ' "Cancel" error codes
Resume Exit_Point
Case Else
MsgBox Err.Description, vbExclamation, "Error " & Err.Number
Resume Exit_Point
End Select
End Sub
I suspect the method isn't supported. I'm not at all familiar with DAO but would that be the way to do it?