S
Stephen Lynch
Can someone check my code. I keep getting a "loop without Do" error. If I
add another end if it just keeps running.
Thanks
*****************************************************
Private Sub LstboxLoansPending_DblClick(Cancel As Integer)
Dim rs As DAO.Recordset
Dim StrSQL As String
Dim strEmployeeIDContFile As String
Dim strEmployeeContAmt As Currency
EmployeeID = Me!LstboxLoansPending.Column(7)
ContributionAmt = Me!LstboxLoansPending.Column(3)
StrSQL = "SELECT tblContributionsTEMP.EmployeeID, tblContributionsTEMP.Loan1
AS LoanAmt " & vbCrLf & _
"FROM tblContributionsTEMP " & vbCrLf & _
"WHERE (((tblContributionsTEMP.Loan1)>0)); " & vbCrLf & _
"UNION SELECT tblContributionsTEMP.EmployeeID, tblContributionsTEMP.Loan2 AS
LoanAmt " & vbCrLf & _
"FROM tblContributionsTEMP " & vbCrLf & _
"WHERE (((tblContributionsTEMP.Loan2)>0)); " & vbCrLf & _
"UNION SELECT tblContributionsTEMP.EmployeeID, tblContributionsTEMP.Loan3 AS
LoanAmt " & vbCrLf & _
"FROM tblContributionsTEMP " & vbCrLf & _
"WHERE (((tblContributionsTEMP.Loan3)>0)); " & vbCrLf & _
"UNION SELECT tblContributionsTEMP.EmployeeID, tblContributionsTEMP.Loan4 AS
LoanAmt " & vbCrLf & _
"FROM tblContributionsTEMP " & vbCrLf & _
"WHERE (((tblContributionsTEMP.Loan4)>0));"
Set rs = CurrentDb.OpenRecordset(StrSQL, dbOpenDynaset)
Do While Not rs.EOF
strEmployeeIDContFile = rs.Fields("EmployeeID")
strEmployeeContAmt = rs.Fields("LoanAmt")
If strEmployeeIDContFile = EmployeeID Then
MsgBox "Found"
Else
MsgBox "Not Found"
rs.MoveNext
Loop
'MsgBox "Notfound"
End If
add another end if it just keeps running.
Thanks
*****************************************************
Private Sub LstboxLoansPending_DblClick(Cancel As Integer)
Dim rs As DAO.Recordset
Dim StrSQL As String
Dim strEmployeeIDContFile As String
Dim strEmployeeContAmt As Currency
EmployeeID = Me!LstboxLoansPending.Column(7)
ContributionAmt = Me!LstboxLoansPending.Column(3)
StrSQL = "SELECT tblContributionsTEMP.EmployeeID, tblContributionsTEMP.Loan1
AS LoanAmt " & vbCrLf & _
"FROM tblContributionsTEMP " & vbCrLf & _
"WHERE (((tblContributionsTEMP.Loan1)>0)); " & vbCrLf & _
"UNION SELECT tblContributionsTEMP.EmployeeID, tblContributionsTEMP.Loan2 AS
LoanAmt " & vbCrLf & _
"FROM tblContributionsTEMP " & vbCrLf & _
"WHERE (((tblContributionsTEMP.Loan2)>0)); " & vbCrLf & _
"UNION SELECT tblContributionsTEMP.EmployeeID, tblContributionsTEMP.Loan3 AS
LoanAmt " & vbCrLf & _
"FROM tblContributionsTEMP " & vbCrLf & _
"WHERE (((tblContributionsTEMP.Loan3)>0)); " & vbCrLf & _
"UNION SELECT tblContributionsTEMP.EmployeeID, tblContributionsTEMP.Loan4 AS
LoanAmt " & vbCrLf & _
"FROM tblContributionsTEMP " & vbCrLf & _
"WHERE (((tblContributionsTEMP.Loan4)>0));"
Set rs = CurrentDb.OpenRecordset(StrSQL, dbOpenDynaset)
Do While Not rs.EOF
strEmployeeIDContFile = rs.Fields("EmployeeID")
strEmployeeContAmt = rs.Fields("LoanAmt")
If strEmployeeIDContFile = EmployeeID Then
MsgBox "Found"
Else
MsgBox "Not Found"
rs.MoveNext
Loop
'MsgBox "Notfound"
End If