Hi Friends,
Got stuck up with Error LoopwithoutDo- But I do have the Do ....
Also checked for misssing End If's again and again; they are all there..
Following is the code, had a working code with subloops which were working perfect, but then I tried to put those in Loop- so that the query would run over each of the selected test names to delete them, but with the addition of this (rs) getting Loop without Do error,
Plz help-Checked tried everything but only got a headache till yet,
Thanks to all of you in advance.....
================>
Got stuck up with Error LoopwithoutDo- But I do have the Do ....
Also checked for misssing End If's again and again; they are all there..
Following is the code, had a working code with subloops which were working perfect, but then I tried to put those in Loop- so that the query would run over each of the selected test names to delete them, but with the addition of this (rs) getting Loop without Do error,
Plz help-Checked tried everything but only got a headache till yet,
Thanks to all of you in advance.....
================>
Code:
'===========================>>>>>
strfrm = "TestBookingUnboundB"
DoCmd.SetWarnings (WarningsOff)
strreg = Form_TestBookingUnboundB.RegistrationID
Set db = CurrentDb
strtoid = Form_TestBookingUnboundB.txttoid
strtid = strtoid
'strtnid = Me.txtTID
'==========================>>>>>
Set rs = db.OpenRecordset("Select * From TempTestSelectorTbl Where ChkSelect=-1")
Me.Requery
With rs
rs.MoveFirst
Do
strTestName = rs("TestName")
strtnid = strTestName
If DLookup("ReportCat", "TestName", "TestNameID= " & strTestName & " ") = 22 Then
DoCmd.RunSQL ("Delete * FROM CultureReport WHERE TestOrderID = " & strtoid & ")")
End If
If DLookup("NonValue", "TestName", " TestNameID =" & strTestName & "") = 0 Then
'C1
DoCmd.RunSQL ("Delete * FROM NonProfileTests WHERE TestName= " & strTestName & " AND TestOrderID=" & strtoid & "")
DoCmd.RunSQL ("Delete * FROM TmpTestSelectorTbl WHERE TestName= " & strTestName & "")
'====21/8/17===>Enter payment and repaint the TBUB form============>
'==Check if payent has been made , then enter the value in payments tbl=======
If IsNull(Form_TestBookingUnboundB.txtPayment) = False Then
strpymnt = Form_TestBookingUnboundB.txtPayment
Set rspymnt = db.OpenRecordset("Payments")
rspymnt.AddNew
rspymnt("PaymentRefID").Value = strtoid
rspymnt("AmountPaid").Value = strpymnt
rspymnt("PaymentDept").Value = Form_TestBookingUnboundB.txtprefixid
rspymnt("RegistrationID").Value = Form_TestBookingUnboundB.RegistrationID
rspymnt("PaymentMode").Value = Form_TestBookingUnboundB.txtPaymentMode
rspymnt.Update
End If
'==Check if payent has been made , then enter the value in payments tbl=======END====
Me.Requery
DoCmd.SetWarnings (WarningsOn)
Form_TestReviewUnboundB.RecordSource = ("SELECT TestName, TestCost, TestOrderID, BookedTest FROM NonProfileTests WHERE ((TestOrderID = " & strtoid & ") AND (BookedTest= -1))")
Form_TestBookingUnboundB.txtAmount = DSum("TestCost", "NonProfileTests", "TestOrderID = " & strtoid & " ")
Form_TestBookingUnboundB.txttoid = strtoid
Form_TestBookingUnboundB.txttoid.Visible = True
DoCmd.SetWarnings (WarningsOn)
'------------copied code-----------
strtotalamnt = Nz(DSum("TestCost", "NonProfileTests", "TestOrderID = " & strtoid & " "), 0)
strtotalpaid = Nz(DSum("AmountPaid", "Payments", "PaymentRefID = " & strtoid & " "), 0)
strdscnt = Nz(DLookup("BkDscnt", "BkOrdrTbl", "BkOrdrTblID = " & strtoid & ""), 0)
'=================
Form_TestBookingUnboundB.txtAmount = strtotalamnt
Form_TestBookingUnboundB.txtTotalPayable = (strtotalamnt - strdscnt) - strtotalpaid
Form_TestBookingUnboundB.txtTotalPaid = strtotalpaid
Form_TestBookingUnboundB.txtPayment = 0
'-------------------------------
DoCmd.SetWarnings (WarningsOn)
'======If the tests selected fordeletion was not a profile then complete following actions>>>>>
Exit Sub
End If ' C1
'===If the test is not a profile delete & Exit Recalculate form TBUE =<<<<<<
'==========================<<<<<
'DEPTH I=>>>
'---If Its a Culture test then add to culture form---------
'DEPTH I=>>> DoCmd.RunSQL ("Delete * FROM CultureReport WHERE TestOrderID= " & strtoid & "")
'DoCmd.RunSQL ("Delete * FROM TmpTestSelectorTbl WHERE TestName= " & strtnid & "")
'End If
'-------x------Add to culture report code ends here----------x---x-----x---------------------------
'DEPTH I=>>>'--Check if its a Profile----------------
If DLookup("NonValue", "TestName", " TestNameID =" & strtnid & "") = -1 Then
'==========Get individual profile tests using ProfileDetailTbl and sort them====16/8/17===
'DEPTH I=>>>
' Set rstn = mydb.OpenRecordset("SELECT Inprofile.value FROM TestName WHERE TestNameID = " & strtnid & " ", dbOpenDynaset)
Set rstn = mydb.OpenRecordset("SELECT * FROM ProfileDetailTbl WHERE ProfileName = " & strtnid & " ", dbOpenDynaset)
Set rsnpt = mydb.OpenRecordset("SELECT TestName FROM NonProfileTests WHERE TestOrderID = " & strtoid & " ")
'---------------Loop through all the individual tests of a profile (Inprofile.value)-------------
With rstnRecordset
'DEPTH I=>>>
rstn.MoveFirst
Do
rsnpt.FindFirst "TestName=" & rstn("InProfileTest") & ""
Debug.Print rstn("InProfileTest")
'rsnpt.Delete
'DoCmd.RunSQL ("Delete * FROM TmpTestSelectorTbl WHERE TestName= " & rstn("InProfileTest") & "")
'------IF the-added test in a profile is a culture itself then---- add to culture form----------------------
If DLookup("ReportCat", "TestName", "TestNameID= " & rsnpt("TestName") & " ") = 22 Then
DoCmd.RunSQL ("Delete * FROM TmpTestSelectorTbl WHERE TestName= " & rsnpt("TestName") & "")
DoCmd.RunSQL ("Delete * FROM CultureReport WHERE TestOrderID = " & strtoid & ")")
End If
'-------x-----InProfile added --Add to culture report code ends here----------x---x-----x---------------------------
'----------||-If the inserted test itself is a profile then insert related tests-||-------'" & rstn("Inprofile.value") & "'
'DEPTH II=>>>
If DLookup("NonValue", "TestName", "TestNameID = " & rsnpt("TestName") & "") = -1 Then
Set rstnsub = mydb.OpenRecordset("SELECT * FROM ProfileDetailTbl WHERE ProfileName = " & rsnpt("TestName") & "", dbOpenDynaset)
With rstnsubRecordset
rstnsub.MoveFirst
'DEPTH II=>>>
Do
Set rsnpt1 = mydb.OpenRecordset("SELECT * FROM NonProfileTests WHERE TestOrderID = " & strtoid & " ")
If IsNull(rstnsub("InProfileTest")) = False Then
'--Check if the test does not already exist in NPT tbl------------
'DEPTH II=>>>
rsnpt1.FindFirst "TestName= " & rstnsub("InProfileTest") & ""
rsnpt1.Delete
DoCmd.RunSQL ("Delete * FROM TmpTestSelectorTbl WHERE TestName= " & rstnsub("InProfileTest") & "")
End If
'--V-Movenext fr 3rd DO -- rstnsub-----------------
' End If
rstnsub.MoveNext
Loop While Not rstnsub.EOF
'==Before exiting loop in DEPTH-II delete the profile name=>>>
'DoCmd.RunSQL ("Delete * FROM NonProfileTests WHERE TestName= " & rsnpt("TestName") & " AND TestOrderID=" & strtoid & "")
'DoCmd.RunSQL ("Delete * FROM TmpTestSelectorTbl WHERE TestName= " & rsnpt("TestName") & "")
End With
rstnsub.Close
'-------------------V-Movenext fr 2nd DO -- rstn-----------------irpjil@bsraffiliates.com
End If
DoCmd.RunSQL ("Delete * FROM TmpTestSelectorTbl WHERE TestName= " & rsnpt("TestName") & "")
rsnpt.Delete ' Delete test which startedtheloop
'DoCmd.RunSQL ("Delete * FROM NonProfileTests WHERE TestName= " & rsnpt("TestName") & " AND TestOrderID=" & strtoid & "")
rstn.MoveNext
Loop Until rstn.EOF
'==Before exiting loop in DEPTH-I delete the profile name=>>>
'
End With
rstn.Close
rs.MoveNext
Loop Until rs.EOF
End With
DoCmd.RunSQL ("Delete * FROM NonProfileTests WHERE TestName= " & strtnid & " AND TestOrderID=" & strtoid & "")
DoCmd.RunSQL ("Delete * FROM TmpTestSelectorTbl WHERE TestName= " & strtnid & "")
'-------------------V-Movenext fr 1st DO -- rs-------V End If ( Check for profile------main)------------
'==Delete the TestProfile Name entries from NPT and TTSTbl
'DoCmd.RunSQL ("Delete * FROM NonProfileTests WHERE (TestOrderID = " & strtoid & " AND TestName= " & strtnid & ") ")
'DoCmd.RunSQL ("Delete * FROM TmpTestSelectorTbl WHERE (TestName= " & strtnid & ") ")
'====21/8/17===>Enter payment and repaint the TBUB form============>
Set rs = Nothing
Set rsnpt = Nothing
'==Check if payent has been made , then enter the value in payments tbl=======
If IsNull(Form_TestBookingUnboundB.txtPayment) = False Then
strpymnt = Form_TestBookingUnboundB.txtPayment
Set rspymnt = db.OpenRecordset("Payments")
rspymnt.AddNew
rspymnt("PaymentRefID").Value = strtoid
rspymnt("AmountPaid").Value = strpymnt
rspymnt("PaymentDept").Value = Form_TestBookingUnboundB.txtprefixid
rspymnt("RegistrationID").Value = Form_TestBookingUnboundB.RegistrationID
rspymnt("PaymentMode").Value = Form_TestBookingUnboundB.txtPaymentMode
rspymnt.Update
End If
'==Check if payent has been made , then enter the value in payments tbl=======END====
'=Concatenate Booked tests======>
Me.Requery
DoCmd.SetWarnings (WarningsOn)
Form_TestReviewUnboundB.RecordSource = ("SELECT TestName, TestCost, TestOrderID, BookedTest FROM NonProfileTests WHERE ((TestOrderID = " & strtoid & ") AND (BookedTest= -1))")
Form_TestBookingUnboundB.txtAmount = DSum("TestCost", "NonProfileTests", "TestOrderID = " & strtoid & " ")
Form_TestBookingUnboundB.txttoid = strtoid
Form_TestBookingUnboundB.txttoid.Visible = True
DoCmd.SetWarnings (WarningsOn)
'------------copied code-----------
strtotalamnt = Nz(DSum("TestCost", "NonProfileTests", "TestOrderID = " & strtoid & " "), 0)
strtotalpaid = Nz(DSum("AmountPaid", "Payments", "PaymentRefID = " & strtoid & " "), 0)
strdscnt = Nz(DLookup("BkDscnt", "BkOrdrTbl", "BkOrdrTblID = " & strtoid & ""), 0)
'=================
Form_TestBookingUnboundB.txtAmount = strtotalamnt
Form_TestBookingUnboundB.txtTotalPayable = (strtotalamnt - strdscnt) - strtotalpaid
Form_TestBookingUnboundB.txtTotalPaid = strtotalpaid
Form_TestBookingUnboundB.txtPayment = 0
DoCmd.SetWarnings (WarningsOn)
Set db = Nothing
Set mydb = Nothing
'======If the tests selected fordeletion was not a profile then complete following actions>>>>>
Exit Sub
End If