i am getting error 'there is no current record', when running the code below.
Its getting stuck at - Lrs5.MoveFirst
Its getting stuck at - Lrs5.MoveFirst
Code:
Public Function data_AS() Dim db As Database
Dim Lrs As DAO.Recordset
Dim Lrs1 As DAO.Recordset
Dim Lrs2 As DAO.Recordset
Dim Lrs3 As DAO.Recordset
Dim Lrs4 As DAO.Recordset
Dim Lrs5 As DAO.Recordset
Dim Lrs6 As DAO.Recordset
Dim Lrs7 As DAO.Recordset
Dim LSQL As String
Dim LGST As String
Dim i As Integer, ii As Integer
i = 1
ii = 1
DoCmd.SetWarnings False
Set db = CurrentDb()
LSQL = "Select * from [GE_Turbine_Details]"
Set Lrs = db.OpenRecordset(LSQL)
LSQL = "Select * from [Competition Turbines]"
Set Lrs1 = db.OpenRecordset(LSQL)
LSQL = "Select * from [Wind Speed]"
Set Lrs2 = db.OpenRecordset(LSQL)
LSQL = "Select * from [PPA]"
Set Lrs3 = db.OpenRecordset(LSQL)
LSQL = "Select * from [K-Factor]"
Set Lrs4 = db.OpenRecordset(LSQL)
LSQL = "Select * from Project_Size"
' Set Lrs5 = db.OpenRecordset(LSQL)
' LSQL = "Select * from Project_Constraint"
Set Lrs5 = db.OpenRecordset(LSQL)
LSQL = "Select * from Project_Cons"
Set Lrs6 = db.OpenRecordset(LSQL)
LSQL = "select * from shear_factor"
Set Lrs7 = db.OpenRecordset(LSQL)
DoCmd.RunSQL "delete from test1"
If Lrs.EOF = False Then
Do While Not Lrs1.EOF
'MsgBox Lrs("GE Turbines")
'Lrs.MoveFirst
'Do While Not Lrs1.EOF
'MsgBox Lrs1("GE Turbines")
Lrs2.MoveFirst
Do While Not Lrs2.EOF
'MsgBox Lrs2("GE Turbines")
Lrs3.MoveFirst
Do Until Lrs3.EOF
Lrs4.MoveFirst
Do Until Lrs4.EOF
Lrs5.MoveFirst
'Lrs6.MoveFirst
Do Until Lrs5.EOF
Lrs6.MoveFirst
Do Until Lrs6.EOF
Lrs7.MoveFirst
Do Until Lrs7.EOF
Lrs.MoveFirst
Do Until Lrs.EOF
LSQL = "Insert into Test1 values('" & Lrs("GeTurbine") & "'"
LSQL = LSQL & " ,'" & Lrs1("Competitors turbines") & "'," & IIf(IsNull(Lrs("GE_Price")), 0, Lrs("GE_Price")) & "," & IIf(IsNull(Lrs("GE_TT_Transportation")), 0, Lrs("GE_TT_Transportation")) & "," & IIf(IsNull(Lrs("GE_CE_Installation")), 0, Lrs("GE_CE_Installation")) & "," & IIf(IsNull(Lrs("GE_BPO")), 0, Lrs("GE_BPO")) & "," & IIf(IsNull(Lrs("GE_Other_Capital_Cost")), 0, Lrs("GE_Other_Capital_Cost")) & "," & IIf(IsNull(Lrs("GE_Planned_FSA_Escalation")), 0, Lrs("GE_Planned_FSA_Escalation")) & "," & IIf(IsNull(Lrs("GE_Planned_FSA_Contract_Year")), 0, Lrs("GE_Planned_FSA_Contract_Year")) & "," & IIf(IsNull(Lrs("GE_Planned_FSA_Contract_Periond")), 0, Lrs("GE_Planned_FSA_Contract_Periond")) & "," & IIf(IsNull(Lrs("GE_Planned_Unplanned_ONM")), 0, Lrs("GE_Planned_Unplanned_ONM")) & "," & IIf(IsNull(Lrs("GE_Hub_Height_1")), 0, Lrs("GE_Hub_Height_1"))
LSQL = LSQL & " ,'" & Lrs("GeTurbine_2") & "'," & IIf(IsNull(Lrs("GE_Price_2")), 0, Lrs("GE_Price_2")) & "," & IIf(IsNull(Lrs("GE_TT_Transportation_2")), 0, Lrs("GE_TT_Transportation_2")) & "," & IIf(IsNull(Lrs("GE_CE_Installation_2")), 0, Lrs("GE_CE_Installation_2")) & "," & IIf(IsNull(Lrs("GE_BPO_2")), 0, Lrs("GE_BPO_2")) & "," & IIf(IsNull(Lrs("GE_Other_Capital_Cost_2")), 0, Lrs("GE_Other_Capital_Cost_2")) & "," & IIf(IsNull(Lrs("GE_Planned_FSA_Escalation_2")), 0, Lrs("GE_Planned_FSA_Escalation_2")) & "," & IIf(IsNull(Lrs("GE_Planned_FSA_Contract_Year_2")), 0, Lrs("GE_Planned_FSA_Contract_Year_2")) & "," & IIf(IsNull(Lrs("GE_Planned_FSA_Contract_Periond_2")), 0, Lrs("GE_Planned_FSA_Contract_Periond_2")) & "," & IIf(IsNull(Lrs("GE_Planned_Unplanned_ONM_2")), 0, Lrs("GE_Planned_Unplanned_ONM_2")) & "," & IIf(IsNull(Lrs("GE_Hub_Height_2")), 0, Lrs("GE_Hub_Height_2"))
LSQL = LSQL & " ,'" & Lrs("GeTurbine_3") & "'," & IIf(IsNull(Lrs("GE_Price_3")), 0, Lrs("GE_Price_3")) & "," & IIf(IsNull(Lrs("GE_TT_Transportation_3")), 0, Lrs("GE_TT_Transportation_3")) & "," & IIf(IsNull(Lrs("GE_CE_Installation_3")), 0, Lrs("GE_CE_Installation_3")) & "," & IIf(IsNull(Lrs("GE_BPO_3")), 0, Lrs("GE_BPO_3")) & "," & IIf(IsNull(Lrs("GE_Other_Capital_Cost_3")), 0, Lrs("GE_Other_Capital_Cost_3")) & "," & IIf(IsNull(Lrs("GE_Planned_FSA_Escalation_3")), 0, Lrs("GE_Planned_FSA_Escalation_3")) & "," & IIf(IsNull(Lrs("GE_Planned_FSA_Contract_Year_3")), 0, Lrs("GE_Planned_FSA_Contract_Year_3")) & "," & IIf(IsNull(Lrs("GE_Planned_FSA_Contract_Periond_3")), 0, Lrs("GE_Planned_FSA_Contract_Periond_3")) & "," & IIf(IsNull(Lrs("GE_Planned_Unplanned_ONM_3")), 0, Lrs("GE_Planned_Unplanned_ONM_3")) & "," & IIf(IsNull(Lrs("GE_Hub_Height_3")), 0, Lrs("GE_Hub_Height_3"))
LSQL = LSQL & " ,'" & Lrs("GeTurbine_4") & "'," & IIf(IsNull(Lrs("GE_Price_4")), 0, Lrs("GE_Price_4")) & "," & IIf(IsNull(Lrs("GE_TT_Transportation_4")), 0, Lrs("GE_TT_Transportation_4")) & "," & IIf(IsNull(Lrs("GE_CE_Installation_4")), 0, Lrs("GE_CE_Installation_4")) & "," & IIf(IsNull(Lrs("GE_BPO_4")), 0, Lrs("GE_BPO_4")) & "," & IIf(IsNull(Lrs("GE_Other_Capital_Cost_4")), 0, Lrs("GE_Other_Capital_Cost_4")) & "," & IIf(IsNull(Lrs("GE_Planned_FSA_Escalation_4")), 0, Lrs("GE_Planned_FSA_Escalation_4")) & "," & IIf(IsNull(Lrs("GE_Planned_FSA_Contract_Year_4")), 0, Lrs("GE_Planned_FSA_Contract_Year_4")) & "," & IIf(IsNull(Lrs("GE_Planned_FSA_Contract_Periond_4")), 0, Lrs("GE_Planned_FSA_Contract_Periond_4")) & "," & IIf(IsNull(Lrs("GE_Planned_Unplanned_ONM_4")), 0, Lrs("GE_Planned_Unplanned_ONM_4")) & "," & IIf(IsNull(Lrs("GE_Hub_Height_4")), 0, Lrs("GE_Hub_Height_4"))
LSQL = LSQL & " ," & IIf(IsNull(Lrs1("Price")), 0, Lrs1("Price")) & "," & IIf(IsNull(Lrs1("TT_Transportation")), 0, Lrs1("TT_Transportation")) & "," & IIf(IsNull(Lrs1("CE_Installation")), 0, Lrs1("CE_Installation")) & "," & IIf(IsNull(Lrs1("BPO")), 0, Lrs1("BPO")) & "," & IIf(IsNull(Lrs1("Other_Capital_Cost")), 0, Lrs1("Other_Capital_Cost")) & "," & IIf(IsNull(Lrs1("Planned_FSA_Escalation")), 0, Lrs1("Planned_FSA_Escalation")) & "," & IIf(IsNull(Lrs1("Planned_FSA_Contract_Year")), 0, Lrs1("Planned_FSA_Contract_Year")) & "," & IIf(IsNull(Lrs1("Planned_FSA_Contract_Period")), 0, Lrs1("Planned_FSA_Contract_Period")) & "," & IIf(IsNull(Lrs1("Planned_Unplanned_ONM")), 0, Lrs1("Planned_Unplanned_ONM")) & "," & IIf(IsNull(Lrs1("Com_Hub_Height")), 0, Lrs1("Com_Hub_Height"))
LSQL = LSQL & " ," & Lrs2("Speed")
LSQL = LSQL & " ," & Lrs3("PPA")
LSQL = LSQL & " ," & Lrs4("K-Factor")
LSQL = LSQL & " ," & Lrs5("project_size")
LSQL = LSQL & " ,'" & Lrs6("project_constraint") & "'"
LSQL = LSQL & "," & Lrs7("Shear_Factor") & ");"
DoCmd.RunSQL LSQL
Lrs.MoveNext
i = i + 1
ii = ii + 1
Loop
If ii > 2 Then
Lrs7.MoveNext
ii = 1
End If
Loop
If i > 2 Then
Lrs6.MoveNext
Lrs5.MoveNext
i = 1
End If
Loop
'Lrs6.MoveNext
'Lrs5.MoveNext
Loop
Lrs4.MoveNext
Loop
Lrs3.MoveNext
Loop
Lrs2.MoveNext
Loop
Lrs1.MoveNext
Loop
End If
'Lrs1.MoveNext
'Loop
'MsgBox "Done"
DoCmd.SetWarnings True
End Function