Using SQL to update / edit records
Posted on 2001-06-24
Here is another problem - I know how to search for items and populate items, what I am having trouble with is adding new records, and updating existing ones with code, I can do this just fine with ADO control, but I wind up with a ton of them all over my forms, How do you "Bind" Code to a text box so you could do something like:
rs.addnew 'Blanking all text boxes for the new entries then
Saving the data in the text boxes to the database, or
rs.update after altering the data in a textbox to save it.
Below is some of the code to search and populate textboxes - But I haven't been succesful after searching MSDN library and the net add or update with just code.
Dim strSQL As String
'If txtSKUNum.Text = txtLastSKU Then Exit Sub
'txtLastSKU = txtSKUNum.Text
strSQL = "SELECT ItemDesc, SellPrice,Category,Type,Image from NewItems " & _
"Where ItemDesc like '" & "%" & Text1.Text_ & "%'"
On Error Resume Next
On Error GoTo 0
rs.Open strSQL, cn, adOpenForwardOnly, adLockReadOnly
If Text1.Text = "" Then
MsgBox "Please enter a search term"
Do Until rs.EOF = True
Check = rs!Itemdesc
List2.AddItem Format(rs!SellPrice, "$####.##")
If rs.EOF = True And Check = "" Then
MsgBox "Sorry No matches found"
Set rs = Nothing
All help is appreciated.