No data for result

meenctg

Learn24bd
Local time
Tomorrow, 03:36
Joined
May 8, 2012
Messages
133
I have two form base on query. where i one has a parameter another has two parameter

as like

First one
Enter your value:

Second one
Enter your id:
Enter your code:

For the first form i set the code at Form open

Code:
  Private Sub Form_Open(Cancel As Integer)     
On Error Resume Next         If Me.RecordsetClone.RecordCount = 0 Then 
        DoCmd.CancelEvent 
        MsgBox "Your entered data is invalid or reult not found", , "Sorry!"         Exit Sub         End If 
 End Sub

It works

but if i set the code for two parameter values the mean second form
it works but it gives another message that like form open action was canceled.

What's the problem? any one tell me that how can i solve this problem.
 
Move to the last record of the recordset before checking recordcount. Not doing so will return an unpredictable value.
 
Move to the last record of the recordset before checking recordcount. Not doing so will return an unpredictable value.
You don't have to move last to find out if there are records. If the recordcount is 0, there are no records. If the record count is <> 0 then there are records. This works regardless of using linked Access or ODBC tables. The only time you have to movelast is when you want the actual count and only for linked tables.

The issue is more likely HOW the forms are being opened.
 
I cann't do it. Yet to it's gives another message.
Would you edit my code please?
 
Simply this:
Code:
Private Sub Form_Open(Cancel As Integer)
    If Me.Recordset.RecordCount < 1 Then
        Cancel = True
        MsgBox "Your entered data is invalid or reult not found", , "Sorry!"
    End If
End Sub
 
The last code snippet shows an example of how to check the number of records bound to a form.l
 
Alright, but that's already what the OP is doing. I guess the link helps to explain RecordsetClone.
 

Users who are viewing this thread

Back
Top Bottom