Need the best way to tackle this issue...

S

Scott Tilton

I am hoping someone here might be able to at least point me in the right
direction on how to tackle this issue. Let me explain...

We have a main form that is based on a contact. Then there is a subform
that has case information. This is a one to many relationship (many cases
for one contact). Then, there is a subform within cases that has payment
information. Up to this point, it is all working fine. Here is what I am
trying to do:

In the case subform I have a button that when clicked on brings up a small
form (dialog box) where the user needs to fill in the following:

First Payment Date
Payment Amount
Term (# of years or months depending on Pay Out selection)
Pay Out (Either Yearly or Montly)

What I want to happen is when they click ok on this form, it will auto-fill
payments into the payments table. For example, Lets say the user entered:

Case ID: 78459384 (Already filled in field on form)
First Payment Date: 1/15/2005
Payment Amount: $2,506.00
Term: 10
Pay Out: Yearly

When they click ok, then in the payments table, it would enter something
like this:

Case ID Amount Date
78459384 $2,506.00 1/15/2005
78459384 $2,506.00 1/15/2006
78459384 $2,506.00 1/15/2007
78459384 $2,506.00 1/15/2008
78459384 $2,506.00 1/15/2009

etc. up to the term entered. In this case 10 years.
Now, if it had been set has Payout Monthly, then it would be going up by 1
month instead of year.

I hope I explained well what I am trying to do. Is there anyone that can
help. If someone could give me either code examples, or even just get me
started in the right direction, that would be awesome. Thanks in advance.

-Scott-
 
K

Kevin Sprinkel

Here is what I am
trying to do:
In the case subform I have a button that when clicked on brings up a small
form (dialog box) where the user needs to fill in the following:

Case ID: 78459384 (Already filled in field on form)
First Payment Date: 1/15/2005
Payment Amount: $2,506.00
Term: 10
Pay Out: Yearly

I've not done this myself, so I can't give you specific
code examples, but, in pseudocode:

Define variables to hold user-entered controls values

Define an array or object class variable to hold the
values for the record to insert

'Read form values into variables
intCase = Me!txtCaseID
dteFirst = Me!dteFirstPaymentDate
curAmount = Me!txtPaymentAmount
intTerm = Me!txtTerm
strPayOutType = Me!txtPayOut

If strPayOutType = "Y" Then
Increment = <one year>
Else
Increment = <one month>
End If

' Open recordset
' Set the array values

For i = 1 to Terms
NewRec(0)= intCase
NewRec(1) = dteFirst + (i-1)* increment
NewRec(2) = curAmount
' Write record using the AddNew method
End Loop

' Close recordset

HTH
Kevin Sprinkel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top