🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.databases.ms-access
Article #193

Re: How can I limit the number of records in a table? (MS Access)

#193
From: Trevor Best
Date: Mon, 04 May 1998 00:00
39 lines
2157 bytes
On Sun, 3 May 1998 21:26:49 +0100 in comp.databases.ms-access, Scott
Mordecai <Scott@musicman.demon.co.uk> wrote:
>Hi, I hope I can make some sense here...
>
>I have a form which has basic record details (person's name, telephone
>number, etc.). On this form is a datasheet sub-form where I can list a
>number of items. I would like to limit the number of entries on this
>datasheet.
>
>e.g. the datasheet has two fields, "Name" (linked to the main record
>table) and "Item". I would like each "Name" to be allowed only a maximum
>number of items.
>
>Any help, if the above makes any sense, is appreciated!

Assuming the foreign key in the subforms recordset is called "FK" then:

Sub Form_BeforeInsert(Cancel As Integer)
  If DCount("*","ThisTable","FK = " & Me!FK)>=3 Then
    Cancel = True
    Msgbox "Rassssssssssssp!"
  End If
End Sub

You can replace DCount() with tCount() from the downloads section of my
FAQ, it's usually faster than DCount, especially over networks.

                    \|||/
                    /   \
                   C o o D
-----------------ooO--u--Ooo-------------------------------
To reply by mail, replace the "nospam" in my address with "trevor",
then replace the "o" in easynot with an "e".
But please DONT cc me in on posts, I read this group as well.
MS Access FAQ now available on my site below.
http://www.trevor.easynet.co.uk/

Roget's Thesaurus rules - ok, all right, very well, you bet, certainly
Technical Details
Message-ID: <35640a0b.6616746@news.easynet.co.uk>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <cUehgLAJMNT1Ewmx@musicman.demon.co.uk>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 1036bc,d87e857d2b30eade
X-Google-Attributes: gid1036bc,public
X-Google-Thread: ff0ac,d87e857d2b30eade
X-Google-Attributes: gidff0ac,public
From: nospam@easynet.co.uk (Trevor Best)
Subject: Re: How can I limit the number of records in a table? (MS Access)
Date: 1998/05/04
Message-ID: <35640a0b.6616746@news.easynet.co.uk>
X-Deja-AN: 349951692
Content-Transfer-Encoding: 7bit
References: <cUehgLAJMNT1Ewmx@musicman.demon.co.uk>
Content-Type: text/plain; charset=us-ascii
Organization: Viasys Limited
Mime-Version: 1.0
Reply-To: nospam@easynot.co.uk
Newsgroups: comp.databases.ms-access,demon.tech.pc