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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

update values in txtboxes

Status
Not open for further replies.

VBVines

MIS
Jun 11, 1999
98
US
I have a form that has text boxes that need to be updated. I am using this code. When I do a mouse over after toggling a breakpoint the rs!whatever seems to be holding the edited value but for some reason the rs.addnew or the rs.update isn't working. Here is my code. Thanks for any help

Private Sub CmdSave_Click()
Dim ssql As String
Dim valdetail As String
Dim rs As Recordset
Dim conn As ADODB.Connection

Set conn = New ADODB.Connection
With conn
.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Administration;Data Source=SOLOFIND"
.Open

Set rs = New ADODB.Recordset
rs.CursorType = adOpenKeyset
rs.LockType = adLockOptimistic
'rs.Open "Resolution", conn, , , adCmdTable

ssql = "Select * from resolution Where res_id = '" & Cmbres.Text & "'"
rs.Open ssql, conn, adOpenKeyset, adLockOptimistic, adCmdText

rs.AddNew

'rs!res_id = "" & TxtRes_id
rs!fname = "" & Txtfname
rs!lname = "" & Txtlname
rs!retailer = "" & txtret
'rs!ProDate = "" & txtdate
'rs!phone = "" & txtphone
rs!detail = "" & txtresolution
'rs!category = "" & txtother
'rs!staff = valstaff
'rs!loggedon_id = frmlogin.val1
'rs!category = valcat
rs!staffdate = "" & txtresolvedate

rs.Update

MsgBox "Datebase Updated"

valdetail = "" & rs!detail

End With


aspvbwannab
 
Code:
Private Sub CmdSave_Click()
    Dim ssql As String
    Dim valdetail As String
    Dim rs As Recordset
    Dim conn As ADODB.Connection
    Set conn = New ADODB.Connection
[b][COLOR=blue]    With conn[/color][/b]
        .ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Administration;Data Source=SOLOFIND"
        .Open
        Set rs = New ADODB.Recordset
        rs.CursorType = adOpenKeyset
        rs.LockType = adLockOptimistic
        'rs.Open "Resolution", conn, , , adCmdTable
        ssql = "Select * from resolution Where res_id = '" & Cmbres.Text & "'"
        rs.Open ssql, conn, adOpenKeyset, adLockOptimistic, adCmdText
[b][COLOR=blue]    End With[/color][/b]
[b][COLOR=red]    With rs[/color][/b]
        rs.AddNew
        'rs!res_id = "" & TxtRes_id
        rs!fname = "" & Txtfname
        rs!lname = "" & Txtlname
        rs!retailer = "" & txtret
        'rs!ProDate = "" & txtdate
        'rs!phone = "" & txtphone
        rs!Detail = "" & txtresolution
        'rs!category = "" & txtother
        'rs!staff = valstaff
        'rs!loggedon_id = frmlogin.val1
        'rs!category = valcat
        rs!staffdate = "" & txtresolvedate
        rs.Update
        MsgBox "Datebase Updated"
        valdetail = "" & rs!Detail
[b][COLOR=red]    End With[/color][/b]

________________________________________
Zameer Abdulla
Visit Me
There is only one perfect child in this world. Every mother has it.
 
Zameer - thanks but that didn't do it either. I ended up remming out the rs.addnew and just keeping the rs.update the same and I was able to edit the textboxes.

aspvbwannab
 
Are you trying to edit the existing record that currently view on the form or adding it as a new record? IF editing then you have to replace .AddNew to .Edit

________________________________________
Zameer Abdulla
Visit Me
A child may not be able to lift too much.
But it can certainly hold a marriage together
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top