borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (Multiple Dbase Connections)Next Topic (How to Place a Datalist on top a frame) New Topic New Poll Post Reply
AndreaVB Forum : Database : VB code in Access
Poster Message
Amiga2000
Level: Professor

Registered: 31-10-2002
Posts: 77

icon 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
View Profile Send Email to User Show All Posts | Quote Reply
JLRodgers
Level: Moderator

Registered: 04-04-2002
Posts: 1617
icon 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
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
Amiga2000
Level: Professor

Registered: 31-10-2002
Posts: 77
icon 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
View Profile Send Email to User Show All Posts | Quote Reply
JLRodgers
Level: Moderator

Registered: 04-04-2002
Posts: 1617
icon 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
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
Amiga2000
Level: Professor

Registered: 31-10-2002
Posts: 77
icon Re: Re: Re: Re: VB code in Access

okay i'll try this out thursday.
Thanks for the code.

Greetings,
John

20-01-2003 at 04:10 PM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : Database : VB code in Access
Previous Topic (Multiple Dbase Connections)Next Topic (How to Place a Datalist on top a frame) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder