Assess fee on a monthly basis automatically

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a main form and a subform. The main form holds client information;
name, account #, etc. The subform is to record new payments on accounts. I
would like to automatically assess a five dollar fee on the first of every
month. I am not quite sure how to go about this. Any suggestions?

Thanks!
 
Ami said:
I have a main form and a subform. The main form holds client information;
name, account #, etc. The subform is to record new payments on accounts. I
would like to automatically assess a five dollar fee on the first of every
month. I am not quite sure how to go about this. Any suggestions?

First you must see if the fee has already been assessed for this month. To
do that, you count the records after the first of the month. So:

Function FirstOfThisMonth() As Variant
' PURPOSE : Returns the first day of the current month.
FirstOfThisMonth = DateSerial(Year(Date), Month(Date), 1)
End Function

Then you can run a query:

SELECT MyTable.DateField
FROM MyTable
WHERE (((MyTable.DateField)>FirstOfThisMonth()));

And if it returns a record, exit the sub, or if not add a record:

INSERT INTO MyTable ( [DateField], [CurrencyField] )
SELECT FirstOfThisMonth() AS Expr1, 5 AS Expr2;

If you need more help, post back.
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access
 
Thank you so much for your help! I was struggling.

Ami

Arvin Meyer said:
Ami said:
I have a main form and a subform. The main form holds client information;
name, account #, etc. The subform is to record new payments on accounts. I
would like to automatically assess a five dollar fee on the first of every
month. I am not quite sure how to go about this. Any suggestions?

First you must see if the fee has already been assessed for this month. To
do that, you count the records after the first of the month. So:

Function FirstOfThisMonth() As Variant
' PURPOSE : Returns the first day of the current month.
FirstOfThisMonth = DateSerial(Year(Date), Month(Date), 1)
End Function

Then you can run a query:

SELECT MyTable.DateField
FROM MyTable
WHERE (((MyTable.DateField)>FirstOfThisMonth()));

And if it returns a record, exit the sub, or if not add a record:

INSERT INTO MyTable ( [DateField], [CurrencyField] )
SELECT FirstOfThisMonth() AS Expr1, 5 AS Expr2;

If you need more help, post back.
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access
 

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

Back
Top