Update

klwu

Brainy!!
Local time
Tomorrow, 05:15
Joined
Sep 13, 2004
Messages
47
Hi all,

I have another problem :( :eek:

When a form is open, I want to change a specific field data to something else (e.g. from 'New' to 'Read'). I wrote the code using UPDATE statement however, when I debug, it keeps giving me error. Could someone guide me please? Thanks

Code:
Private Sub Form_Current()
Dim sSql As String
Dim dbs As Database

sSql = "UPDATE T_IMPanel SET MsgStatus = 'Read' WHERE MsgRef = '" & txtMsgRef & "'"
Set dbs = CurrentDb
dbs.Execute sSql
If dbs.RecordsAffected <> 1 Then
    MsgBox "Internal Error", vbOKOnly, "ERROR"
End If

End Sub
 
rather than that code you can simply put

Me.Fieldname = "Read"
 
Max,

I tried your code, it doesn't work. I went to check the table, and the field data still remains 'New'. Anyway, I appreciate your help. :) Thanks
 
what is the name of the field which you want to update ? And which event are you using the code in ?
 
Max,

Your code works! I just went to double check my code, and realise I did something silly. :o :o ......Thanks for your help :D
 

Users who are viewing this thread

Back
Top Bottom