ADO Function Needed
From: Toco (Toco_at_discussions.microsoft.com)
Date: 09/28/04
- Next message: Duncan Dimech: "Remote Database Connection"
- Previous message: Ben: "RE: How to Query Offline in ADO.NET"
- Next in thread: ScottShell: "Re: ADO Function Needed"
- Reply: ScottShell: "Re: ADO Function Needed"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 28 Sep 2004 13:11:05 -0700
Hello. I have an ADO statement that executes the same query, in the body of
a case statement. I seem to repeat the same ADO call because the
.RecordCount is dynamic, even though the actual SQL is the same. My goal is
to create a function that executes the query, opens the recordset, then
returns a .RecordCount. Is it possible to implement this using a Function,
that uses the .RecordCount as the return value? That way I can call the
function from within the case statements? As it stands now I have dimmed
about 5 different strSQL and rstCounts, all within one Select Case statement.
This is very unmanaged, spaghetti code I have going. Here is the ADO
procedure I have repeated 5 times for every case option
Dim strSQL1 As String, rstOne As New ADODB.Recordset
strSQL1 = "Select custID from tbCustomerLetters"
rstOne.Open strSQL1, CurrentProject.Connection, adOpenStatic,
adLockReadOnly
With rstOne
If .RecordCount = 0 Then
MsgBox "No customers were processed in your query", 64 +
0, "No Letters printed"
GoTo ExitPrint
End If
If MsgBox("Continue?", vbYesNo, "There are " & .RecordCount
& " Letters to be printed ") = vbYes Then
Call PrintReport("rptCustomerLetter")
Else
rstOne.Close
End If
End With
Next Case Statement---
Toco
- Next message: Duncan Dimech: "Remote Database Connection"
- Previous message: Ben: "RE: How to Query Offline in ADO.NET"
- Next in thread: ScottShell: "Re: ADO Function Needed"
- Reply: ScottShell: "Re: ADO Function Needed"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|