B
Brad Holderman
Greetings,
I recently tweaked some code by entering a DCount expression, based on an
earlier post.
The original code simply presented criteria arguments in opening a table and
it worked fine. What I wanted to do is add a simple "No records found"
handler that would take me back to the switchboard.
However, once I ran the new change, VB didn't have a problem with the DCount
expression, what it now has a problem with is the "End Sub" command. I now
receive an error, "Block If Without End If."
I will post the code below, but first my question. Has the DCount changed
the structure of the Sub? And, do I simply have the DCount in the wrong
place?
Any help would be appreciated, and here is the code:
Private Sub Form_Open(Cancel As Integer)
If Me.OpenArgs <> "" Then
'The OpenArgs should be delimited with a | character
'Get the OpenArgs into individual strings in an array
Dim strArgs() As String
strArgs = Split(Me.OpenArgs, "|")
Dim strCustomer As String
Dim strJob As String
Dim strType As String
Dim strTemp() As String
Dim I As Integer
For I = 1 To UBound(strArgs)
strTemp = Split(strArgs(I), "=")
Select Case strTemp(1)
Case "Customer"
strCustomer = strTemp(2)
Case "Job"
strJob = strTemp(2)
Case "Type"
strType = strTemp(2)
End Select
Next
Dim strSQL As String
strSQL = "SELECT .Customer, " & _
"Job, " & _
"Type , " & _
"[Sub-Type] , " & _
"[Sub-type2] , " & _
"Size , " & _
"[Job No] , " & _
"Field8 , " & _
"Field9 , " & _
"Priority , " & _
"[Project Lead] , " & _
"[Date Scanned] , " & _
"[Addendum Status] , " & _
"Status , " & _
"[Last Accessed] , " & _
"[Drive Location] , " & _
"[Image Count] , " & _
"[Document Type] , " & _
"Viewed_By_Brad " & _
"FROM EDDIE" & _
WhereClauseBuild
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
rs.CursorLocation = adUseClient
rs.Open strSQL, CurrentProject.Connection, adOpenDynamic,
adLockOptimistic
Me.Recordset = rs
Else
If DCount("*", "EDDIE", "") = 0 Then
MsgBox "No records found"
End If
End Sub
I recently tweaked some code by entering a DCount expression, based on an
earlier post.
The original code simply presented criteria arguments in opening a table and
it worked fine. What I wanted to do is add a simple "No records found"
handler that would take me back to the switchboard.
However, once I ran the new change, VB didn't have a problem with the DCount
expression, what it now has a problem with is the "End Sub" command. I now
receive an error, "Block If Without End If."
I will post the code below, but first my question. Has the DCount changed
the structure of the Sub? And, do I simply have the DCount in the wrong
place?
Any help would be appreciated, and here is the code:
Private Sub Form_Open(Cancel As Integer)
If Me.OpenArgs <> "" Then
'The OpenArgs should be delimited with a | character
'Get the OpenArgs into individual strings in an array
Dim strArgs() As String
strArgs = Split(Me.OpenArgs, "|")
Dim strCustomer As String
Dim strJob As String
Dim strType As String
Dim strTemp() As String
Dim I As Integer
For I = 1 To UBound(strArgs)
strTemp = Split(strArgs(I), "=")
Select Case strTemp(1)
Case "Customer"
strCustomer = strTemp(2)
Case "Job"
strJob = strTemp(2)
Case "Type"
strType = strTemp(2)
End Select
Next
Dim strSQL As String
strSQL = "SELECT .Customer, " & _
"Job, " & _
"Type , " & _
"[Sub-Type] , " & _
"[Sub-type2] , " & _
"Size , " & _
"[Job No] , " & _
"Field8 , " & _
"Field9 , " & _
"Priority , " & _
"[Project Lead] , " & _
"[Date Scanned] , " & _
"[Addendum Status] , " & _
"Status , " & _
"[Last Accessed] , " & _
"[Drive Location] , " & _
"[Image Count] , " & _
"[Document Type] , " & _
"Viewed_By_Brad " & _
"FROM EDDIE" & _
WhereClauseBuild
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
rs.CursorLocation = adUseClient
rs.Open strSQL, CurrentProject.Connection, adOpenDynamic,
adLockOptimistic
Me.Recordset = rs
Else
If DCount("*", "EDDIE", "") = 0 Then
MsgBox "No records found"
End If
End Sub