473,548 Members | 2,593 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

What is Best Method to Limit Number of Records

I have created a table and form for allowing the input of a unique
customer number (not an ID autonumber number) which a customer would
enter once after installing the database. I'm using DLookup to obtain
the value which works. What I need assistance with is the best method
to use to ensure that only ONE customer number can be entered. A quick
attempt to structure a piece of code is shown below. Any assistance
will be appreciated. Thanks, Dalan

Private Sub Form_AfterUpdat e() ? or ?

Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim RecordCount As String
RecordCount = "CustomerNo "
Set db = CurrentDb()
Set rs = db.OpenRecordse t("tblCustomerN o")
With rs
.MoveFirst
If RecordCount = 0 Or 1 Then
MsgBox "Only one Customer Number is allowed to be entered"

' Need code to limit the number of records to only 1

End If
.Close
End With
Set rs = Nothing
Set db = Nothing

End Sub
Nov 12 '05 #1
2 2007
"Dalan" <ot***@safe-mail.net> wrote in message
news:50******** *************** ***@posting.goo gle.com...
I have created a table and form for allowing the input of a unique
customer number (not an ID autonumber number) which a customer would
enter once after installing the database. I'm using DLookup to obtain
the value which works. What I need assistance with is the best method
to use to ensure that only ONE customer number can be entered. A quick
attempt to structure a piece of code is shown below. Any assistance
will be appreciated. Thanks, Dalan

Private Sub Form_AfterUpdat e() ? or ?

Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim RecordCount As String
RecordCount = "CustomerNo "
Set db = CurrentDb()
Set rs = db.OpenRecordse t("tblCustomerN o")
With rs
.MoveFirst
If RecordCount = 0 Or 1 Then
MsgBox "Only one Customer Number is allowed to be entered"

' Need code to limit the number of records to only 1

End If
.Close
End With
Set rs = Nothing
Set db = Nothing

End Sub

If you are talking about having a table to contain things like MyCompany,
MyAddress, MyPhone, etc so there is only ever one record in the database,
then I would enforce it at table-level. Just put a validation rule in the
field so that ID=1, that way the no code is involved and it can't be
by-passed.

Fletcher
Nov 12 '05 #2
If you just want a table with one record in then create a field in it
as follows:

Name: OnlyOneRecord
Type: Number, Long
Indexed: Yes (No Duplicates)
Validation Rule: =1
Default Value: 1

--
A)bort, R)etry, I)nfluence with large hammer.
Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
6792
by: Ravi Tallury | last post by:
Hi We are having issues with our application, certain portions of it stop responding while the rest of the application is fine. I am attaching the Java Core dump. If someone can let me know what the issue is. Thanks Ravi
6
5766
by: JohnH | last post by:
I have an ASP app (developed with Interdev 6) which uses a DTC listbox (server-side) bound to a recordset to allow the user to make a selection. This works fine until the number of records in the record set seems to hit a limit (not determined the exact limit, but seems to be c. 400). If there are too many records, the app just hangs until...
6
12340
by: Hannu | last post by:
Hi. In the ldb file you can see the users of the mdb-file. If you open the mdb-file your machine and username will be written in the lbd- file. Allthough you close the mdb-file your name won't disappear from the ldb-file, before every user has closed the mdb-file. I have heard that there will be problems if the amount of users will be over...
3
6629
by: deko | last post by:
Is there any way to limit the number of records loaded into a ListBox? I looked at qdf.MaxRecords (to apply to the query that is the RowSource of the ListBox) but that only applies to ODBC data sources. I also looked at Tools > Options > Edit/Find and tried setting the "Don't display lists where more than this number of records read:"...
9
13749
by: campbellwarren | last post by:
Does anyone know how I could limit the number of rows allowed in a MS Access table... want to limit it to 1.
2
9146
by: someone | last post by:
How can I limit the number of records a Query retrieves or at least limit the number of records returned on a report. I only want to print the top 5 or 10 returns of a query into a weekly reort. Thank you -- ---------------------------------------------- Posted with NewsLeecher v3.0 Final
669
25604
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Language”, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic paper written on this subject. On the Expressive Power of Programming Languages, by Matthias Felleisen, 1990....
1
1962
by: dfw1417 | last post by:
I have used a query and report filter to return records related to a specific account id. I want to print a report including only the latest 6 records out of the set returned by the record filter. I have set the sort order for the report on descending thus returning the latest records at the top of the report. However since there are well over 6...
4
1853
bilibytes
by: bilibytes | last post by:
Hello i'm intrigued by what happens behind the scenes when I do a DB query to a database from php. I would like to know what is the exact life cycle of a mysql_query() I ask this question because i need to know what is the best solution to count the number of rows from a query. My query is performed to fetch records from a mysqlDb that...
0
7512
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main...
0
7707
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7466
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7803
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5362
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3495
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1926
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1051
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
751
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.