Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open a form only if recordcount > 1

Status
Not open for further replies.

dead7

Programmer
Jun 8, 2004
79
US
Trying to have a form open only if the recordcount is > 1.
does this look right or am I off base. The field Im concerned with is a claim# field. If there is more than one claim then an additional form should open if theres more than one claim, thats why Im using the recordcount.


If Me.RecordsetClone.RecordCount > 1 Then
DoCmd.OpenForm stDocName2, , , stLinkCriteria2
End If
 
You can try the above code...

If you get any error message or If the form stDocName2 is not opening then let us know...

Regards,
 
Well it is opening the form even if the record count is > 1
 
You may also consider the DCount function.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
This is a common error, you're going to have to use the .MoveLast routine before using the .RecordCount property, otherwise you'll get an inaccurate count. See these threads for details:
--
Find common answers using Google Groups:

Corrupt MDBs FAQ
 
Here is two methods; both can be used in different occasions.
First one for entire table and the second more suitable for controlling number of entries per group.
Code:
'Checking entire table for count
Private Sub cmdAddNew_Click()
    If DCount("*", "TableName") >= 20 Then
        MsgBox "No More"
    Else
        DoCmd.GoToRecord , , acNewRec
    End If
End Sub
'================================================

'Checking for form's available recordset.

Private Sub cmdAddNew_Click()
    If Me.RecordsetClone.RecordCount >= 20 Then
        MsgBox "No More"
    Else
        DoCmd.GoToRecord , , acNewRec
    End If
End Sub

________________________________________________________
Zameer Abdulla
Help to find Missing people
Even a thief takes ten years to learn his trade.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top