Amiga2000 Level: Professor Registered: 31-10-2002 Posts: 77
VB code in Access
Private Sub CountRecords()
Dim Counter as Integer
Dim strSqlEx as String
If cboStatus = "Closed" Or cboStatus = "Running" Then
gstrStatus = cboStatus
Else
Exit Sub
End If
strSqlEx = "SELECT COUNT(*) FROM Voorbereiding " _
& "WHERE status = '" & gstrStatus & "' "
Counter = Val(strSqlEx)
End Sub
I have 1 record with status "Closed" But still Counter = 0
I used Val to convert the string to a integer.
also tried Cint(strqEx) which gave me compile error.
So can anyone help me out with this code ?
[Edited by Amiga2000 on 17-01-2003 at 11:50 AM GMT]
17-01-2003 at 10:23 AM
|
JLRodgers Level: Moderator Registered: 04-04-2002 Posts: 1617
Re: VB code in Access
strSqlEx is a recordset (the way you're using it)
strSqlEx.Fields(0).Value or strSqlEx.Fields(0) should work
[Edited by JLRodgers on 17-01-2003 at 08:22 AM GMT]
____________________________ Everywhere's Local (classifieds, job postings, & more for everycity in the world - user entered)
17-01-2003 at 02:22 PM
|
Amiga2000 Level: Professor Registered: 31-10-2002 Posts: 77
Re: Re: VB code in Access
I get compile error: invalid qualifier
Dim strSqlEx As String
If cboStatus = "Afgesloten" Or cboStatus = "Overleg" Then
gstrStatus = cboStatus
Else
Exit Sub
End If
strSqlEx.Fields(0).Value = "SELECT COUNT(*) FROM Voorbereiding " _
& "WHERE status = '" & gstrStatus & "' "
Teller = Val(strSqlEx.Fields(0).Value)
MsgBox Teller
End Sub
What's the correct syntax JL ?
20-01-2003 at 09:46 AM
|
JLRodgers Level: Moderator Registered: 04-04-2002 Posts: 1617
Re: Re: Re: VB code in Access
Dim rsSqlEx As Recordset
If cboStatus = "Afgesloten" Or cboStatus = "Overleg" Then
gstrStatus = cboStatus
Else
Exit Sub
End If
' You'd have to have a connection variable
rsSqlEx = connectionVariable.Execute "SELECT COUNT(*) FROM Voorbereiding " _
& "WHERE status = '" & gstrStatus & "' "
' == OR ==
rsSqlEx.Open "SELECT COUNT(*) FROM Voorbereiding " _
& "WHERE status = '" & gstrStatus & "' ", ConnectionVariable
Teller = Val(strSqlEx.Fields(0).Value)
MsgBox Teller
End Sub
[Edited by JLRodgers on 20-01-2003 at 09:32 AM GMT]
[Edited by JLRodgers on 20-01-2003 at 09:34 AM GMT]
____________________________ Everywhere's Local (classifieds, job postings, & more for everycity in the world - user entered)
20-01-2003 at 03:32 PM
|
Amiga2000 Level: Professor Registered: 31-10-2002 Posts: 77
Re: Re: Re: Re: VB code in Access
okay i'll try this out thursday.
Thanks for the code.