I have a database that has multiple records for a single individual.
For example, for a database that has the following fields for each
loan.
Member Loan Int
# # Rate Balance
11 1 .06 10,000
22 1 .07 10,000
22 2 .05 5,000
33 1 .04 20,000
44 1 .07 5,000
44 2 .07 10,000
44 3 .06 10,000
I want to create another database with one record for each borrower.
My problem is there can be anywhere from 1 to 10 loans per borrower. I
also want to include any savings/checking/certificate accounts in the
record and there may be up to 30 separate accounts or more. I have
started to write code, but something tells me there is a better way.
Any suggestions would be greatly appreciated.
Code
Option Compare Database
Public Function Tomtest()
Dim memno As Integer
Dim ln1, ln2, ln3, ln4, ln5, ln6, ln7, ln8, ln9, ln10 As String
Dim lt1, lt2, lt3, lt4, lt5, lt6, lt7, lt8, lt9, lt10 As String
Dim lb1, lb2, lb3, lb4, lb5, lb6, lb7, lb8, lb9, lb10 As Double
Dim db As Database
Dim rst As Recordset
Set db = CurrentDb()
Set rst = db.OpenRecordset("Tbl_Combined_Share_Loan")
Set Rst1 = db.OpenRecordset("Tbl_Tomtest")
rst.MoveFirst
Do Until rst.EOF
Do While rst![Loan No] = ""
rst.MoveNext
Loop
memno = rst![Member No]
ln1 = rst![Loan No]
lt1 = rst![lnty]
lr1 = rst![LoanRate]
lb1 = rst![LnBal]
rst.MoveNext
If rst![Member No] = memno Then
ln2 = rst![Loan No]
lt2 = rst![lnty]
lr2 = rst![LoanRate]
lb2 = rst![LnBal]
rst.MoveNext
If rst![Member No] = memno Then
ln3 = rst![Loan No]
lt3 = rst![lnty]
lr3 = rst![LoanRate]
lb3 = rst![LnBal]
rst.MoveNext
End If
End If
With Rst1
.AddNew
!memno = memno
!ln1 = ln1
!lt1 = lt1
!lr1 = lr1
!lb1 = lb1
!ln2 = ln2
!lt2 = lt2
!lr2 = lr2
!lb2 = lb2
!ln3 = ln3
!lt3 = lt3
!lr3 = lr3
!lb3 = lb3
.Update
End With
ln1 = ""
ln1 = ""
lr1 = 0
lb1 = 0
ln2 = ""
ln2 = ""
lr2 = 0
lb2 = 0
ln3 = ""
ln3 = ""
lr3 = 0
lb3 = 0
rst.MoveNext
Loop
End Function
Thanks for any advice you can give. 2 2039
BeanCounterCPA wrote: I have a database that has multiple records for a single individual. For example, for a database that has the following fields for each loan.
Member Loan Int # # Rate Balance
11 1 .06 10,000 22 1 .07 10,000 22 2 .05 5,000 33 1 .04 20,000 44 1 .07 5,000 44 2 .07 10,000 44 3 .06 10,000
I want to create another database with one record for each borrower. My problem is there can be anywhere from 1 to 10 loans per borrower. I also want to include any savings/checking/certificate accounts in the record and there may be up to 30 separate accounts or more. I have started to write code, but something tells me there is a better way. Any suggestions would be greatly appreciated.
Code
Option Compare Database
Public Function Tomtest()
Dim memno As Integer Dim ln1, ln2, ln3, ln4, ln5, ln6, ln7, ln8, ln9, ln10 As String Dim lt1, lt2, lt3, lt4, lt5, lt6, lt7, lt8, lt9, lt10 As String Dim lb1, lb2, lb3, lb4, lb5, lb6, lb7, lb8, lb9, lb10 As Double
Dim db As Database Dim rst As Recordset Set db = CurrentDb() Set rst = db.OpenRecordset("Tbl_Combined_Share_Loan") Set Rst1 = db.OpenRecordset("Tbl_Tomtest")
rst.MoveFirst
Do Until rst.EOF
Do While rst![Loan No] = "" rst.MoveNext Loop
memno = rst![Member No] ln1 = rst![Loan No] lt1 = rst![lnty] lr1 = rst![LoanRate] lb1 = rst![LnBal]
rst.MoveNext
If rst![Member No] = memno Then
ln2 = rst![Loan No] lt2 = rst![lnty] lr2 = rst![LoanRate] lb2 = rst![LnBal]
rst.MoveNext
If rst![Member No] = memno Then
ln3 = rst![Loan No] lt3 = rst![lnty] lr3 = rst![LoanRate] lb3 = rst![LnBal]
rst.MoveNext
End If End If
With Rst1 .AddNew !memno = memno !ln1 = ln1 !lt1 = lt1 !lr1 = lr1 !lb1 = lb1 !ln2 = ln2 !lt2 = lt2 !lr2 = lr2 !lb2 = lb2 !ln3 = ln3 !lt3 = lt3 !lr3 = lr3 !lb3 = lb3
.Update End With
ln1 = "" ln1 = "" lr1 = 0 lb1 = 0 ln2 = "" ln2 = "" lr2 = 0 lb2 = 0 ln3 = "" ln3 = "" lr3 = 0 lb3 = 0
rst.MoveNext
Loop
End Function
Thanks for any advice you can give.
Maybe you can do a SQL Select that uses a Pivot table and groups on the
fields you want. You might have to UNION the data prior to the Pivot
query to handle multiple acounts.
"BeanCounterCPA" <tn*******@snavely.us> wrote in
news:11**********************@o13g2000cwo.googlegr oups.com: I have a database that has multiple records for a single individual. For example, for a database that has the following fields for each loan.
Member Loan Int # # Rate Balance
11 1 .06 10,000 22 1 .07 10,000 22 2 .05 5,000 33 1 .04 20,000 44 1 .07 5,000 44 2 .07 10,000 44 3 .06 10,000
I want to create another database with one record for each borrower. My problem is there can be anywhere from 1 to 10 loans per borrower. I also want to include any savings/checking/certificate accounts in the record and there may be up to 30 separate accounts or more. I have started to write code, but something tells me there is a better way. Any suggestions would be greatly appreciated.
[code snipped]
Thanks for any advice you can give.
The best advice is not to do it. Doing so would violate
normalisation rules and give you headaches down the road.
You can handle the situation easily with subforms that show the
loans and accounts for a member.
For reporting purposes, you can build a CrossTab query. The
wizard is pretty good at this.
--
Bob Quintal
PA is y I've altered my email address. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: mark |
last post by:
Access2000
How do I write a query that combines the CTC field from each record below into
one record? I need to concatenate the CTC field with a separator, like below:
...
|
by: snOOp |
last post by:
I am trying to combine the data from two similar tables into one
query, but I need for all of the records from both tables to show up
and I want the ones that have matching 'emplid' to be combined...
|
by: mojo |
last post by:
We have set up an Access database with tables x,y, & z where we would
like to have multiple people entering data into a table x. Each person
has an identical copy of the database on their PC's. ...
|
by: jhutchings |
last post by:
Hello everyone,
I have a database where I collect shipment data from various tables.
However, I have a problem. Whenever I want to see shipping data for
orders that were set to ship on or before...
|
by: musicloverlch |
last post by:
I have a table with multiple records in it. I am being forced to
combine multiple records into one record in order to be uploaded to a
website, and I only get one record per client. How can I...
| |
by: rdraider |
last post by:
Hi all,
We have an app that uses SQL 2000. I am trying to track when a code field
(selcode) is changed on an order which then causes a status field (status)
to change. I tried a trigger but...
|
by: tromped |
last post by:
I need to know urgently how to combine 2 records in 1.
|
by: ryanvmcgee |
last post by:
Hello,
I am fairly new at doing advanced databases outside of excel.
I am trying to combine records in a database I will be using, none of the, CONCAT Queries or scripts I have found seem to...
|
by: NCRStinks |
last post by:
Hi Every1
Having a slight issue on creating a query to combine 2 queries, this year and last years data.
The thing is, I have data for this year for all stores, however on last year I dont for...
|
by: bluereign |
last post by:
Thank you for your assistance. I am a novice looking to JOIN and append or combine records from 2 current Tables into 2 new Tables named below. I have been able to JOIN Tables with the script...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |
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,...
|
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: 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...
|
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...
|
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...
|
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...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |