I am trying to have a user enter values via an interface and continue to run the program but the following line (Select...) fails to work most of the time as part of the program (although it works fine when you entered in a MapBasic window).

Dim Lat As Float
Dim Lon As Float
Dim sIDENT As String
Dim sValue As String

Control StaticText
  Position 150,50
  Title "Enter ID ?"

Control EditText
  Position 150,70
  Width 50 Height 15
  ID 99
  Value " " ' default value
  Into sValue

Select Lon, Lat from TableA where sIDENT = sValue into Querry
  • You say it fails most of the time - when does it fail and when does it work? What data type is your column IDENT? – Peter Horsbøll Møller Aug 22 '14 at 6:45
  • sorry, that was a typo IDENT is actually sIDENT. – user3405572 Aug 22 '14 at 15:43
  • Can you please edit you question to make the code correct? Make sure you don't have a variable names the same as a column – Peter Horsbøll Møller Aug 22 '14 at 17:40
  • Modifications have been made. – user3405572 Aug 22 '14 at 19:49

You appear to have two float variables named Lon and Lat as well as selecting the same names as columns in your SQL select. Change your variable names and that should resolve the problem.


Add this to your code instead your 'Select' line

Dim sqlcom as string

sqlcom = "Select Lon, Lat from TableA where sIDENT = """ + sValue + """ into Query"
run command sqlcom

Actually I realize that the programme was causing me problems because I needed to define the svalue variable as a fixed length variable string.

Dim sValue As String *5 (for example a length 5 string)

Otherwise the selection process in the Table would not grant me a value all the time roughly only 1 out of 10 times.

  • No, that can't be it. Fixed length strings will have spaces added after the actual value. Does you column also hold values in this way? – Peter Horsbøll Møller Aug 23 '14 at 13:57
  • The column contains 5 and 6 character strings. When the fixed length is specified the select function returns a value from a query on the table. – user3405572 Aug 29 '14 at 20:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.