473,493 Members | 2,229 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

autonumbers, updating tables, and user entries

Hi folks.

I have 2 tables, AccList and Book.

Book has ISBN as its primary key, while AccList has AccNo as its
primary key (data type = Autonumber) and ISBN as its foreign key.

The entries in AccList goes something like this:

AccNo ISBN
----- ----
00010 1234
00011 1234
00012 1234
00013 9876
00014 9876
00015 9876

Book and AccList are linked in a 1-to-many relationship (Book = 1,
AccList = many).

I have a form, frmAddBook, that is based on Book. frmAddBook has the
text boxes "ISBN" and "Total", in which the user enters the ISBN of
the new book and the number of copies of that book, respectively. Is
it possible for the form to automatically generate the AccNo of
AccList (starting from 00016 as per the example above) based on
"Total" and fill in the ISBN field in Book (for example, the user
enter "Total" as 3 and "ISBN" as 159; AccList wil then have the
entries 00016, 00017, 00018, and 00019, with 159 assigned to each of
them)? If yes, how do I do it?
Nov 12 '05 #1
1 1263
Aravind wrote:
Hi folks.

I have 2 tables, AccList and Book.

Book has ISBN as its primary key, while AccList has AccNo as its
primary key (data type = Autonumber) and ISBN as its foreign key.

The entries in AccList goes something like this:

AccNo ISBN
----- ----
00010 1234
00011 1234
00012 1234
00013 9876
00014 9876
00015 9876

Book and AccList are linked in a 1-to-many relationship (Book = 1,
AccList = many).

I have a form, frmAddBook, that is based on Book. frmAddBook has the
text boxes "ISBN" and "Total", in which the user enters the ISBN of
the new book and the number of copies of that book, respectively. Is
it possible for the form to automatically generate the AccNo of
AccList (starting from 00016 as per the example above) based on
"Total" and fill in the ISBN field in Book (for example, the user
enter "Total" as 3 and "ISBN" as 159; AccList wil then have the
entries 00016, 00017, 00018, and 00019, with 159 assigned to each of
them)? If yes, how do I do it?


You could create a query to get the max value of your acctNo field.
Next, open up the query as a recordset to get the max number.
Then do a for/next and add the records.
Example using air code

Sub AddRecs
Dim i As Integer
Dim lA As Long
Dim r As Recordset
Dim rAdd As Recordset
Dim s As STring

Set rAdd = Currentdb.openrecordset("Table1",dbopendynaset)
s = "Select Max(AcctNo) As MA from Table1"
set r = currentdb.openrecordset(s,dbopensnapshot)

'convert to integer the value of acctno
ia = CLng(r!MA)

For i = 1 to Me.TotalRecs
ia = IA + 1
rAdd.AddNew
rAdd!AcctNo = Format(ia,"00000")
rAdd!ISBN = Me.ISBN
rAdd.Update
Next i
rAdd.close
r.close
set rAdd = Nothing
set r = Nothing

msgbox "Done adding records!"
End Sub
Nov 12 '05 #2

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

Similar topics

7
2479
by: Paige | last post by:
I have a database on my local machine that I make entries and corrections on. I'd like to be able to upload that to my server and have that update the database that's on the server. What I've been...
3
3557
by: Poul Møller Hansen | last post by:
Hi, I need an auto incrementing field that will contain values like N000001, N000002, N000003 etc. I think the way is to use the value from an identity field in a stored procedure that is...
2
2267
by: Megan | last post by:
Hi everybody- I have 2 tables, Hearings and Rulings. Both have primary keys called, CaseID, that are autonumbers. I don't want both tables to have the same autonumber. For example, if Hearings...
1
1672
by: Christa Waggett | last post by:
Hi, I'm not a programmer but would appreciate some help with the following. I've been looking at various sites but cannot find the information I require. I have a table of strata plans and if we...
4
2360
by: Geoff | last post by:
Hi I'm hoping somebody can help me with the following problem that has occurred to me. Suppose I have two tables in an SQL Server database. Let's call these tables A and B. Assume that A has...
1
1817
by: beil.jp | last post by:
Hi All - I'm new to Google Groups and just a novice user of Access, so please forgive me if my question is elementary: I am having a problem using the "update query" for my first time. In my...
33
3254
by: bill | last post by:
In an application I am writing the user can define a series of steps to be followed. I save them in a sql database using the field "order" (a smallint) as the primary key. (there are in the range...
0
3088
by: TechnoAtif | last post by:
<?php include "dbconnect.php"; include "commonFunc.php"; ?> <!----------------------------------> <table width="80%" border="1" cellpadding="2" cellspacing="0"> <tr > <td...
10
2533
by: Phillipe | last post by:
Hi, hope you can help with this query as it's had me stuck for quite a while. I have two tables: user table ----------------- id (primary key) firstname lastname
0
7157
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,...
0
7195
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...
0
7367
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...
0
5453
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
4579
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3088
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
1400
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
644
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
285
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.