w_drury
04-15-2002, 02:09 PM
Is it possible to end a sub routine while in an if statement.
I am trying to populate a review form with data that meets certain criteria and if the last record has been used in the review I want the sub to end before continuing to the next line of code.
I am using ADO and this is the first part of the code:
Dim result As Integer
Dim varBookmark As Variant
frmCategoryReview.Show
result = InputBox("What Category do you want to review?", "Highway Cost Estimation")
'Put in code for loading review items
frmCategoryReview.Show
frmCategoryReview.lblCategoryChosenToReview.Caption = result
With frmCategorySheetDataEntry.Data1.Recordset
.MoveLast
.MoveFirst
Do Until .EOF
If ![Item Cost] > 0 And !Category = result Then
frmCategoryReview.lblRow1ItemNumber.Caption = ![Item Number]
frmCategoryReview.lblRow1Location.Caption = !Location
frmCategoryReview.lblRow1CategoryCode.Caption = ![Category Code]
frmCategoryReview.lblRow1Quantity.Caption = !Quantity
frmCategoryReview.lblRow1UnitCost.Caption = ![Unit Cost]
frmCategoryReview.lblRow1ItemCost.Caption = ![Item Cost]
.MoveNext
If .EOF = True Then
End
Else
varBookmark = frmCategorySheetDataEntry.Data1.Recordset.Bookmark
End If
Exit Do
Else
End If
.MoveNext
Loop
End With
With frmCategorySheetDataEntry.Data1.Recordset
frmCategorySheetDataEntry.Data1.Recordset.Bookmark = varBookmark
Do Until .EOF
If ![Item Cost] > 0 And !Category = result Then
frmCategoryReview.lblRow2ItemNumber.Caption = ![Item Number]
frmCategoryReview.lblRow2Location.Caption = !Location
frmCategoryReview.lblRow2CategoryCode.Caption = ![Category Code]
frmCategoryReview.lblRow2Quantity.Caption = !Quantity
frmCategoryReview.lblRow2UnitCost.Caption = ![Unit Cost]
frmCategoryReview.lblRow2ItemCost.Caption = ![Item Cost]
.MoveNext
If .EOF = True Then
End
Else
varBookmark = frmCategorySheetDataEntry.Data1.Recordset.Bookmark
End If
Exit Do
Else
End If
.MoveNext
Loop
End With
I know end will not work but hopefully you get the idea of what I want.
Thanks
I am trying to populate a review form with data that meets certain criteria and if the last record has been used in the review I want the sub to end before continuing to the next line of code.
I am using ADO and this is the first part of the code:
Dim result As Integer
Dim varBookmark As Variant
frmCategoryReview.Show
result = InputBox("What Category do you want to review?", "Highway Cost Estimation")
'Put in code for loading review items
frmCategoryReview.Show
frmCategoryReview.lblCategoryChosenToReview.Caption = result
With frmCategorySheetDataEntry.Data1.Recordset
.MoveLast
.MoveFirst
Do Until .EOF
If ![Item Cost] > 0 And !Category = result Then
frmCategoryReview.lblRow1ItemNumber.Caption = ![Item Number]
frmCategoryReview.lblRow1Location.Caption = !Location
frmCategoryReview.lblRow1CategoryCode.Caption = ![Category Code]
frmCategoryReview.lblRow1Quantity.Caption = !Quantity
frmCategoryReview.lblRow1UnitCost.Caption = ![Unit Cost]
frmCategoryReview.lblRow1ItemCost.Caption = ![Item Cost]
.MoveNext
If .EOF = True Then
End
Else
varBookmark = frmCategorySheetDataEntry.Data1.Recordset.Bookmark
End If
Exit Do
Else
End If
.MoveNext
Loop
End With
With frmCategorySheetDataEntry.Data1.Recordset
frmCategorySheetDataEntry.Data1.Recordset.Bookmark = varBookmark
Do Until .EOF
If ![Item Cost] > 0 And !Category = result Then
frmCategoryReview.lblRow2ItemNumber.Caption = ![Item Number]
frmCategoryReview.lblRow2Location.Caption = !Location
frmCategoryReview.lblRow2CategoryCode.Caption = ![Category Code]
frmCategoryReview.lblRow2Quantity.Caption = !Quantity
frmCategoryReview.lblRow2UnitCost.Caption = ![Unit Cost]
frmCategoryReview.lblRow2ItemCost.Caption = ![Item Cost]
.MoveNext
If .EOF = True Then
End
Else
varBookmark = frmCategorySheetDataEntry.Data1.Recordset.Bookmark
End If
Exit Do
Else
End If
.MoveNext
Loop
End With
I know end will not work but hopefully you get the idea of what I want.
Thanks