I don't know how to treat a field name parameter in a function

New to Gambas? Post your questions here. No question is too silly or too simple.
Post Reply
User avatar
gambafeliz
Posts: 141
Joined: Friday 2nd September 2022 7:50pm
Location: I live in the same city as Picasso

I don't know how to treat a field name parameter in a function

Post by gambafeliz »

Hi

I need to pass in name of a field to sqlite3 to process it.

But when I try to treat it I don't know how to do it so that it works for me.


' datefield = "[Created  ▽]"  x-----(This field name result is the problem)
' dateSQLite = "2023-10-01"

Public Function sum(resultados As Result, Optional datefield As String = "", Optional dateSQLite As String) As Float
   
   Dim f As Float
   
   While resultados.Available
      If datefield = "" Then
         f += resultados["Amount"]
      Else If resultados[datefield] = dateSQLite Then ' This should work just fine. But, here it breaks because it doesn't recognize the field
         f += resultados["Amount"]         
      Endif
      resultados.MoveNext 
   Wend
   
   Return f
   
End
For your misfortunes I am Spanish and I only know Spanish, please, be patient with me, Thank you. :)
User avatar
gambafeliz
Posts: 141
Joined: Friday 2nd September 2022 7:50pm
Location: I live in the same city as Picasso

Re: I don't know how to treat a field name parameter in a function

Post by gambafeliz »

The solution is to pass the field without [] and then it works fine.

Example: "Created ▽"
For your misfortunes I am Spanish and I only know Spanish, please, be patient with me, Thank you. :)
Post Reply