Good morning all,
Please forgive unsophisticated nature of this question, but I think I have thorough searched the forums and cannot find and answer. For background sake I am a very amateur programmer, but have a decent background with SQL statements, primarily on MS SQL Server, as well as a fair amount of work with Jasper Reports.
I have a very simple SQL table consisting of ID (primary key), CustomerName, Unit, Comments, Status, EntryDate, Branch, Dept for which I am trying to create a user front end. I have provided text fields for the user to enter information and added and button that runs an InsertRecord method when clicked. So far so good.
I then added a ListBox which displays the contents of the database. The fields in the ListBox are ID, CUSTOMER,UNIT, COMMENTS. Again this part is working as intended.
I have tried to add a remove record button and this where I am running into a roadblock. I am setting the celltag on the first column of each row in the listbox as it is populated. I am using the celltag to populate a variable which I can then use in other places - this also seems to be working. I have this code set on the CHANGE event handler:
Dim s As string
If Me.ListIndex <> -1 Then
s=(Me.CellTag(Me.ListIndex,0))
End If
What I want to do is remove the selected record from the SQL table when the user clicks the remove record button. I tried the following code without success.
[code] If mDB Is Nil Then Return
Dim sql As String
sql = “DELETE FROM CTS_PreWO where ID =”’+s //I think this is my problem.
mDB.SQLExecute(sql)
if db.error then //Check for an error
msgbox db.errormessage
//do something else like rollback
else
//No error then commit
db.commit
end[/code]
Yes, I realize that I could just use the celltag info directly in the SQL, however I am trying to learn for future situations where I may need to pass a variable in the future.
Thanks,
Joe