C
Chris Guld
I usually use queries for everything, but I'm trying to
use a SQL Insert statement this time and I can't get the
syntax right. Here's the situation, I have a table of
Franchisees with a key field called 'Source'. I also have
a custom function that figures the minimum royalty that
each Franchisee owes based on their contract type, years
in business etc. RoyaltyMiniumum() - all I have to pass it
is the 'Source' and it does the rest. I want this
procedure to cycle thru all the active franchisees and
enter the minimum royalty they owe for the current month.
It needs to insert a record into tblSales for each
franchisee that includes the Source, Month, Year, Sales of
0, MinimumRoyalty due, an entry date and a sort date.
Here's my non-functioning code:
----------------------------------
Private Sub cmdMinimums_Click()
Dim rFranchisees As Recordset, sSource As String
Set rFranchisees = CurrentDb.OpenRecordset("SELECT Status,
SOURCE FROM [GM CONTACT] WHERE Status= 'active'", _
dbOpenForwardOnly, dbReadOnly)
With rFranchisees
DoCmd.SetWarnings False
Do While Not .EOF
INSERT INTO tblSales (SOURCE, SalesAmount,
RoyaltyAmount, EntryDate, SortDate )
SELECT !Source , 0 , RoyaltyMinimum(!Source),
Format([date],"mm/dd/yy"), Format(Date(),"yyyymm")
.MoveNext
Loop
End With
DoCmd.SetWarnings True
End Sub
-------------------------------
Any help would be appreciated.
Thanx!
Chris
use a SQL Insert statement this time and I can't get the
syntax right. Here's the situation, I have a table of
Franchisees with a key field called 'Source'. I also have
a custom function that figures the minimum royalty that
each Franchisee owes based on their contract type, years
in business etc. RoyaltyMiniumum() - all I have to pass it
is the 'Source' and it does the rest. I want this
procedure to cycle thru all the active franchisees and
enter the minimum royalty they owe for the current month.
It needs to insert a record into tblSales for each
franchisee that includes the Source, Month, Year, Sales of
0, MinimumRoyalty due, an entry date and a sort date.
Here's my non-functioning code:
----------------------------------
Private Sub cmdMinimums_Click()
Dim rFranchisees As Recordset, sSource As String
Set rFranchisees = CurrentDb.OpenRecordset("SELECT Status,
SOURCE FROM [GM CONTACT] WHERE Status= 'active'", _
dbOpenForwardOnly, dbReadOnly)
With rFranchisees
DoCmd.SetWarnings False
Do While Not .EOF
INSERT INTO tblSales (SOURCE, SalesAmount,
RoyaltyAmount, EntryDate, SortDate )
SELECT !Source , 0 , RoyaltyMinimum(!Source),
Format([date],"mm/dd/yy"), Format(Date(),"yyyymm")
.MoveNext
Loop
End With
DoCmd.SetWarnings True
End Sub
-------------------------------
Any help would be appreciated.
Thanx!
Chris