Dim M2FSql1 as String
N=35
For M = 0 To N - 1
For X = M + 2 To N
For Q = 1 To 3
F1=M*N+5
F2=M+1-N*2
OrderN = 2 * Q + 1
cal1 = (Q + 1) * F1 - Q * F2
cal2 = (Q + 1) * F2 - Q * F1
M2FSql1 = "INSERT INTO Intermod (OrderN,IntmodFreq, Freq1, Freq2) "
M2FSql1 = M2FSql1 & "Values(" & OrderN & "," & cal1 & "," & F1 & "," & F2 &
" );"
DoCmd.RunSQL M2FSql1
Next Q
Next X
Next M
I think this approach might be faster:
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb()
Set rs = OpenRecordset(Intermod, dbOpenDynaset)
N=35
For M = 0 To N - 1
For X = M + 2 To N
For Q = 1 To 3
rs.AddNew
F1=M*N+5
F2=M+1-N*2
rs!OrderN = 2 * Q + 1
rs!IntmodFreq= (Q + 1) * F1 - Q * F2
' cal2 = (Q + 1) * F2 - Q * F1
rs!Freq1 = F1
rs!Freq2 = F2
rs!Update
Next Q
Next X
Next M
rs.Close : Set rs = Nothing
Set db = Nothing
--
Marsh
MVP [MS Access]
Perhaps Marshall's solution will work better for you.
Can I ask how often you need to do this? Might you be better off building
the table once and then if you need a limited set of records use a query to
restrict the set of records returned.
--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
.
"Nova" <No...@discussions.microsoft.com> wrote in message
news:E69BB7A7-A051-4ED0...@microsoft.com...
--
HTH,
George
"Nova" <No...@discussions.microsoft.com> wrote in message
news:E69BB7A7-A051-4ED0...@microsoft.com...