I am totally lost - my code seems to be correct, but it produces those 2 crappy errors
The syntax error only occurred after using the line of code below which Albin recommended:
IncidentsRS = IncidentsDB.SQLSelect("SELECT IRef, Number, Type, Date, Involved, Dealing FROM Incidents WHERE IRef="+IRNumber)
Just out of curiosity, what do you get for the value of IRNumber putting the MsgBox statement immediately after where the IRNumber assignment is made, like:
Are you getting what you expected from the list box?
There’s your problem … need to figure out why … essentially, you’re using “” (blank string) as an identifier which will give you those exact same two errors
So basically, the problem must be in these 2 lines of code?
// RETRIEVE VALUES FROM THE SELECTED LISTBOX ROW
Dim IRNumber as String = MainWindow.IncidentsListBox.cell(MainWindow.IncidentsListBox.listindex,0)
IncidentsRS = IncidentsDB.SQLSelect("SELECT IRef, Number, Type, Date, Involved, Dealing FROM Incidents WHERE IRef="+IRNumber)
Ok, I changed this:
// RETRIEVE VALUES FROM THE SELECTED LISTBOX ROW
Dim IRNumber as Integer = MainWindow.IncidentsListBox.cell(MainWindow.IncidentsListBox.ListIndex, 0)
IncidentsRS = IncidentsDB.SQLSelect(“SELECT IRef, Number, Type, Date, Involved, Dealing FROM Incidents WHERE IRef=”+str(IRNumber))
To This:
// RETRIEVE VALUES FROM THE SELECTED LISTBOX ROW
Dim IRNumber as Integer = 1
IncidentsRS = IncidentsDB.SQLSelect(“SELECT IRef, Number, Type, Date, Involved, Dealing FROM Incidents WHERE IRef=”+str(IRNumber))
Wayne,
When I use your second option, and change the hard-coded values - it works as expected.
When I use your 3rd option - I get a syntax error.
This indicates that there is a problem with the listbox selection in the main window?
[quote=130318:@Don Lyttle]Just out of curiosity, what do you get for the value of IRNumber putting the MsgBox statement immediately after where the IRNumber assignment is made, like:
Dim IRNumber as String = MainWindow.IncidentsListBox.cell(MainWindow.IncidentsListBox.listindex,0)
MsgBox IRNumber
Are you getting what you expected from the list box?[/quote]
Stop thrashing and take a step back. The problem is that IRNumber is coming back blank from the listbox. There was nothing wrong with the SQLSelect statement. The problem is the contents of IRNumber, or more specifically the contents of the listbox. So look there.
What is the value of MainWindow.IncidentsListBox.listindex?
Does that row contain a value in column 0?
Tim,
I have spent so many hours looking at this problem, that I have now gone totally brain-dead!
ALL columns in my database contain values - I looked inside the database file.
I tried this code, and I got a syntax error, followed by an empty Msgbox
// RETRIEVE VALUES FROM THE SELECTED LISTBOX ROW
Dim IRNumber as String = MainWindow.IncidentsListBox.cell(MainWindow.IncidentsListBox.ListIndex, 0)
IncidentsRS = IncidentsDB.SQLSelect("SELECT IRef, Number, Type, Date, Involved, Dealing FROM Incidents WHERE IRef="+IRNumber)
MsgBox(MainWindow.IncidentsListBox.cell(MainWindow.IncidentsListBox.ListIndex, 0))
I then tried just this, and also got an empty MsgBox:
All message boxes display the correct column values EXCEPT the one which should display the value for column 0 - which displays an empty msgbox!!!
This seems to indicate that column 0 in my database is empty.
However, if you look at the database file screenshots below, you will clearly see that all of my columns have values.
Also, if I hard code the IRef value, as opposed to using the selected row - it works as expected - also confirming that column 0 has an integer value.
Therefore, the problem MUST be with the following code:
// RETRIEVE VALUES FROM THE SELECTED LISTBOX ROW
Dim IRNumber as String = MainWindow.IncidentsListBox.cell(MainWindow.IncidentsListBox.ListIndex,0)
IncidentsRS = IncidentsDB.SQLSelect("SELECT IRef, Number, Type, Date, Involved, Dealing FROM Incidents WHERE IRef="+IRNumber)
Could it be due to me Dimming IRNumber as a String, when the column IRef is an Integer?