Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

C'est magnifique, mais ce n'est pas l'Informatique. -- Bosquet [on seeing the IBM 4341]


devel / comp.databases.ms-access / Re: Add a defined number of records to a table

SubjectAuthor
o Re: Add a defined number of records to a tableRon Paii

1
Re: Add a defined number of records to a table

<514bea9f-2ab2-49e5-aaf1-9084d8378e51n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=456&group=comp.databases.ms-access#456

  copy link   Newsgroups: comp.databases.ms-access
X-Received: by 2002:a37:ad0d:: with SMTP id f13mr5728784qkm.453.1626095422292;
Mon, 12 Jul 2021 06:10:22 -0700 (PDT)
X-Received: by 2002:a25:d113:: with SMTP id i19mr55535283ybg.180.1626095422085;
Mon, 12 Jul 2021 06:10:22 -0700 (PDT)
Path: i2pn2.org!rocksolid2!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.databases.ms-access
Date: Mon, 12 Jul 2021 06:10:21 -0700 (PDT)
In-Reply-To: <1136312194.048180.66290@f14g2000cwb.googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=65.30.79.18; posting-account=RurhpQoAAACBjKrwaxvElRMdPO3AZiPP
NNTP-Posting-Host: 65.30.79.18
References: <1136312194.048180.66290@f14g2000cwb.googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <514bea9f-2ab2-49e5-aaf1-9084d8378e51n@googlegroups.com>
Subject: Re: Add a defined number of records to a table
From: ron81...@gmail.com (Ron Paii)
Injection-Date: Mon, 12 Jul 2021 13:10:22 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
 by: Ron Paii - Mon, 12 Jul 2021 13:10 UTC

On Tuesday, January 3, 2006 at 12:16:34 PM UTC-6, NV wrote:
> Hi !
> I don't know if it's possible but I need to create in a table as many
> records as a number entered in a form. (Example: In a form I write 4
> and it creates 4 new records in a table).
> In each of those records I need to paste a code of 3 leters and the
> year (Example: In the same form I write in the field code ABC, and in
> the field year 2006, and it enters those values to each of the 4 new
> records).
> Does anybody know how this can be done ?
> Thank you all in advance
> Nuno

When doing multiple table updates, I like to run the edits in a transaction.. The following code can be used in a form's button click event. Replacing "ABC" and "2006" with a field reference. Change the query by replacing YourTable, [CodeCol] and [YearCol] with the proper table and column names. This code will add 4 rows or none.

Private Sub btnAdd4_Click()
on error goto errbtnAdd4_Click
dim transactionActive as boolean
dim add4QueryDef as DAO.QueryDef
transactionActive = false
set add4QueryDef = currentdb.CreateQueryDef(vbnullstring, "PARAMETERS [InsertCode] Text ( 255 ), [InsertYear] Text ( 255 ); INSERT INTO yourTable( [CodeCol], [YearCol]) VALUES([InsertCode], [InsertYear]);
add4QueryDef.Paramiters(0) = "ABC"
add4QueryDef.Paramiters(1) = "2006"
DBEngine.Workspaces(0).BeginTrans
transactionActive = true
add4QueryDef .Execute dbFailOnError + dbSeeChanges
add4QueryDef .Execute dbFailOnError + dbSeeChanges
add4QueryDef .Execute dbFailOnError + dbSeeChanges
add4QueryDef .Execute dbFailOnError + dbSeeChanges
donebtnAdd4_Click:
on error resume next
if transactionActive then
DBEngine.Workspaces(0).CommitTrans
endif
set add4QueryDef = Nothing
exit sub
errbtnAdd4_Click:
debug.print err.Description
if transactionActive then
on error resume next
DBEngine.Workspaces(0).Rollback
endif
transactionActive = false
Resume donebtnAdd4_Click
end Sub

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor