473,498 Members | 1,938 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to start at number 1 for each new record in a related table?

76 New Member
Hello everyone*
I have a quoestion to ask regarding lines like for instance on a quote.
*
I have two tables: QuoteHdr and QuoteDet
*
On QuoteHdr I have fields: QuoteNo, Customer, QuoteDate, CustomerPoNo etc
And on QuoteDet I have*: Line(AutoNumber), Item, Item descr, Qty, Retail, QuoteNo*etc.
I have a 1-many relationship between QuoteNo and QuoteNo.
*
What I want is that when I enter a new quote and I add lines, the lines must start at 1 angain for each new quote.
Do I have to create another table, maybe have a foreign key, what kind of field format should I use?* What should I do?
Please help.
*
For each new QuoteNo, the quote detail lines must start at 1 again -
*
Thanks
Ryno
Feb 8 '11 #1
3 1368
Rabbit
12,516 Recognized Expert Moderator MVP
You can do it at runtime using a ranking query or you can store it by getting the count of the lines for that quote and add 1.
Feb 8 '11 #2
Ryno Bower
76 New Member
Hey, I'm sorry. I don't understand what you are trying to say. Could you please explain or maybe give another suggestion.
Thanks
Feb 8 '11 #3
TheSmileyCoder
2,322 Recognized Expert Moderator Top Contributor
If you make a field called lngQuoteLine and then in your subform (The form you use to enter the quote details) you have an event in either Before_Insert or before_Update where you assign the number to lngQuoteLine.

It could look something like this:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_BeforeInsert(Cancel As Integer)
  2.     Me.tb_LineQuoteNumber = nz(DMax("lngQuoteLine", "tbl_QuoteDetails","lngQuoteNo=" & me.tb_QuoteNo),0)+1
  3. End Sub
Feb 8 '11 #4

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

Similar topics

4
6275
by: Joe User | last post by:
Hi all....I have a feeling this is going to be one of those twisted query questions, but here it goes anyways.... I want to generate a report that shows the chronology of events (represented by...
3
1434
by: Gerry Abbott | last post by:
Hi all, Im using the after update event of a field from a bound form to add records using the recordset object, to a related table. However i'm getting the 3201 error, telling me I must have a...
15
2684
by: Hi5 | last post by:
Hi, I am designing a database for a client in which It has a client table including the followings: 1-Table Client 2-Table lookupcategory 3-Table Ctegory
2
1447
by: PeterW | last post by:
I have a table that includes a field containing a text of the path to a bitmap image related to its record. I am trying to create a report that includes the linked bitmap for each record. The...
2
1525
by: jaYPee | last post by:
At last I have found the problem why I can't get to work w/ importrow. The fact is that I'm trying to import data to related table. But after importing data the foreign is blank. So thats why the...
9
1620
by: MLH | last post by:
I have a source query (qryITSLetterList) feeding rows containing name, addr, city, state, zip and VehicleID to a report (rptITSnotices). The query may contain 1-to-5 records resulting in 1-to-5...
0
1323
by: Marcelo | last post by:
Hi, I have the following need: I list a table from an access database but cannot interact with each record. At the html page I display all records, one field (field1) from and 3 buttons for each...
3
3409
by: bluez | last post by:
I want to design a webpage where user can search the data from the database and list out the related records. Each of the record got a delete button which allow user to delete the record. ...
0
1607
by: mikewilli | last post by:
Warning:: I am very new to programming, having never had to use VBA before, traditionally i am a SQL/Crystal Reports writer... with that in mind: I am currently writing ar eport to extract data...
4
2146
by: QntmPg | last post by:
Hi all, I have read through what I could find on previous questions regarding using the OpenArgs property, but I'm still not able to get my form to open correctly. I'm not sure exactly where the...
0
7125
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
7203
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6885
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...
0
5462
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3093
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...
0
3081
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1417
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 ...
1
656
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
290
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...

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.