Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need UPDATE query help using textboxes in VB6 1

Status
Not open for further replies.

starkmann

Programmer
Jun 25, 2001
2
US
VB is telling me that my field names inside tblClients, such as ClientID are undefined. All I want to do is update a selected record that was loaded into a series of textboxes.

statement = "UPDATE tblClients " & _
"SET (" & _
ClientID = "'" & txtClientID.Text & "', " & _
Addr1 = "'" & txtAddr1.Text & "', " & _
Addr2 = "'" & txtAddr2.Text & ", " & _
City = "'" & txtCity.Text & "', " & _
ClientName = "'" & txtClientName.Text & "', " & _
ShortName = "'" & txtShortName.Text & "', " & _
Comment = "'" & txtComment.Text & "', " & _
Phone = "'" & txtPhone.Text & "', " & _
State = "'" & txtState.Text & "', " & _
Zip = "'" & txtZipCode.Text & "'" & _
")" & _
"WHERE (" & ClientID = "'" & txtClientID.Text & "'" & _
")"

A syntax example or a clue as to where i might find good examples would be a nice clue. THanks for any help you can provide!
Mark
 
try tacking the form name to the front of your element.text expressions:

Like say your form was named 'frmMain', then it would look like this:

frmMain.txtClientID.Text

:)
Paul Prewett
penny.gif
penny.gif
 
Paul is on the right tack, but I think you will need to specify the Forms Collection like so:

Forms!frmMain!txtClientID.Text

Hope that helps! Joe Miller
joe.miller@flotech.net
 
For all responses, Thank you. However after pulling my hair out for a few more days I finally found a solution to my own problem: Use a combo DELETE and INSERT in place of UPDATE. I did get this to work. And for anyone else who may be interested, the code is:


'Perform an UPDATE by first deleting a row, then inserting a whole _
new row based on user input:
strDelSQL = "DELETE * FROM tblClients WHERE ClientName"
strDelSQL = strDelSQL & " = '" & Combo1.Text & "'"
'Combo1.Text holds a list of ClientNames

'build the insert statement:
strAddSQL = "INSERT INTO tblClients VALUES("
For i = 1 To NumCols
strAddSQL = strAddSQL & "'" & txtUpdateClient(i - 1).Text & "'"
'txtUpdateClient is a control array that holds info _
loaded from a recordset and can now be edited.

If i <> NumCols Then
strAddSQL = strAddSQL & &quot;,&quot;
End If
Next i
strAddSQL = strAddSQL & &quot;)&quot;

' Execute the DELETE statement.
conn.Execute strDelSQL, , adCmdText 'PROBLEM HERE!!!!

' Execute the INSERT statement.
conn.Execute strAddSQL, , adCmdText
conn.Close

Thanks Again!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top