Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

New to VBA

Status
Not open for further replies.

aunixguru

IS-IT--Management
Feb 2, 2001
28
US
Hello,
I have been using Access off and on since the old days of Access 2.0.
I am currently using Access 2000.

Pretty much everything I have done has been without doing any coding.

I think I need to do some vba coding to solve a current problem I have.

I have a table called debts and
I have a table called interest.
I need to check if a record exist with debtid=current debtid in interest.

My logic is this:

If there is no record in the interest table, then I am free to calculate interest from datedue and amountowed of current table. Then write record to interest with what I charged and the date charged and the new balance.

If there is a record in interest, then I have to grab the last balance and compare it to the amountowed and calculate new interest. Then write record to interest with what I charged and the date charged and the new balance.

I think you have to use VBA to do this and I have spent much of yesterday looking for tutorials on how to use VBA.

I could find very little on the matter.

Anyway, I will be visiting a bookstore today to get a good book on this. Problem is I really need to solve this problem as soon as possible.

Can anyone help me with the code needed to accomplish this?

Thank You.

 
This will be a bit scetchey as I no field names etc. etc but here goes.
On something that will fire the code I would put:
Intrest(me!amountowed-me!lastbalance, DebID)

This I would put in a module:

Function Interest(Owed, DebID)
Dim MyRe as Dao.recordset, MyDB as Dao.Database
dim Int
int=dlookup("Interest","YrInterestTbl")
set mydb=currentdb
set myre=mydb.oprenrecordset("Select * from debts where DebID=" & debid)
if myre.recordsount=0 then myre.addnew else myre.edit

myre!owed=owed
myre!Interest=owed*(int/100)
myre.update

end function

You would have have some interest pr. day etc. but this should get you started and give you some idear at least.

If you like you can mail me off-line and I will have a look at it.
 
Why not do a query with the common fields the tie field?

rollie@bwsys.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top