473,386 Members | 1,997 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

how to limit number of records displayed in subform in access 2007

547 512MB
i want to limit the capturing in a subform to the first 10 records. Pls help

mainform = racesetupf (table name =racesetup)
fields = racesetupid(autono)
racename(txt); racedate(short)

Subform = RaceTimingSF
Table = RacetimingT
RacetimingId (autonumber)
Finishseq (number)
RaceNo (number)
Racedate (date)
Racename (txt)

The finishseq field adds a sequential number every time a raceno is captured.
What i need is an statement such as "If the value of finishseq =10, then close access. The code in the "beforeinsert" of the subform is
FinishSeq = Nz(DMax("FinishSeq", "RacetimingT")) + 1

pls help
Oct 13 '10 #1

✓ answered by gnawoncents

I think I understand what you're trying to do. See if the code below works and let me know.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_BeforeInsert(Cancel As Integer)
  2.  
  3. FinishSeq = Nz(DMax("FinishSeq", "RacetimingT")) + 1
  4.  
  5. If FinishSeq = 10 then
  6.   cancel = true
  7. End If
  8.  
  9. End Sub 

3 3504
gnawoncents
214 100+
I think I understand what you're trying to do. See if the code below works and let me know.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_BeforeInsert(Cancel As Integer)
  2.  
  3. FinishSeq = Nz(DMax("FinishSeq", "RacetimingT")) + 1
  4.  
  5. If FinishSeq = 10 then
  6.   cancel = true
  7. End If
  8.  
  9. End Sub 
Oct 13 '10 #2
neelsfer
547 512MB
thx a million
Oct 13 '10 #3
neelsfer
547 512MB
just before i got your message, i stumbled across this code that works and is very similar

If Me.Finishseq <10 Then
MsgBox "Maximum records already saved. No more may be added.", vbOKOnly
Cancel = True
Me.Undo
End If
Oct 13 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: tlyczko | last post by:
I have been looking on the NGs and I found this code to show if a subform has no records. I have this code in the MAIN form OnClose event: Private Sub btnClose_Click() '4/16/06 new code that...
1
by: MLH | last post by:
I have a form with a subform control on it listing records returned by a saved query named UnbilledVehicles. I would like to put command buttons on the main form to apply dynamic filters to the...
1
by: David1129 | last post by:
I'm working on testing a large application with Access 2007. It has been running under 2003 and XP with no obvious errors. However with 2007 many forms seem to have lost the ability to filter....
1
by: jmarr02s | last post by:
Is it possible to limit the number of Subform records using MS Access 2003? That is, my end users want the capability of entering up to 12 records on their subform. Is that possible? ...
4
by: lupo666 | last post by:
Hi everybody, this time I have three problems driving me nuts :-((( (1) I have a report with 20 or so Yes/No "squares". Is there a way to either hide/show the "square" or change the yes/no...
5
by: CindySue | last post by:
I'm using a subform linked to the main form by a bidder number field. In the subform, I added a group header and put the field LS in it so that it would list all records designated as Live first...
4
by: TD | last post by:
I am trying to change the forecolor of a field in a subform that is in datasheet view. I am using Access 2007. I have tried everything I can think of to do this but the text still appears in...
9
by: prakashwadhwani | last post by:
Hi !! I'm about to develop a new project for a client. Should I go about it in Access 2003 or 2007 ? Purchasing it either for me or for my client is not a major consideration here ... what I'd...
2
by: JoeKid09 | last post by:
Hi Guys, I'm working on converting a large table with a field that has numeric values in text data type. When I do the conversion in Access automatically some records don't get converted. The...
1
newnewbie
by: newnewbie | last post by:
Hi, Short version: trying to export more than 65K of data from Access 2007 into Excel 2007 (important) through VBA. Access gives me 65K row limitation error, though I thought that was no longer...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...

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.