Modify query error

siddnave2

Registered User.
Local time
Tomorrow, 05:13
Joined
Nov 19, 2015
Messages
16
Hi,

Can any one help me correcting modify script as when it is getting triggered i am getting error for Combo box (", UserSecurity='" & Me.CmbSecurity & "'" & _) ERROR is : Method or data member not found

Vba code given below

'When we clik on button Add there are two options.
'1. for insert
'2. for Update
If Me.TxtUserName & "" * "" Then
'This is for insert new
'Add Records
CurrentDb.Execute "INSERT INTO tbluser(UserName,UserLogin,Password,UserSecurity) VALUES ('" & Me.TxtUserName & "','" & TxtLogin & "','" & txtPassword & "','" & Me.CmbSecurity & "')"
MsgBox "New User Created", vbInformation, "New User Added!"

Else
'Otherwise Modify
CurrentDb.Execute "Update tbluser" & _
" SET UserName='" & Me.TxtUserName & "'" & _
", UserLogin='" & TxtLogin & "'" & _
", Password='" & txtPassword & "'" & _
", UserSecurity='" & Me.CmbSecurity & "'" & _
" WHERE UserName=" & Me.TxtUser.Tag
 
For one thing I believe Me.TxtUser.Tag should be inside single quotes like

" WHERE UserName='" & Me.TxtUser.Tag & "'"
 
Hi,

Still same error method or data not found.

Thanks,
 
Code:
Suggest changing:

Code:
CurrentDb.Execute "Update tbluser" & _
" SET UserName='" & Me.TxtUserName & "'" & _
", UserLogin='" & TxtLogin & "'" & _
", Password='" & txtPassword & "'" & _
", UserSecurity='" & Me.CmbSecurity & "'" & _
" WHERE UserName=" & Me.TxtUser.Tag
To

Code:
Dim strSQL as String
strSQL =  "Update tbluser" & _
" SET UserName='" & Me.TxtUserName & "'" & _
", UserLogin='" & TxtLogin & "'" & _
", Password='" & txtPassword & "'" & _
", UserSecurity='" & Me.CmbSecurity & "'" & _
" WHERE UserName='" & Me.TxtUser.Tag  & "'"
Debug.Print strSQL
CurrentDb.Execute strSQL

and let us know what you get in the immediate window when you run this code.

Also why are you using the tag of TxUser? This seems unusual.
 
Hi Sneburg,

Changed the code suggested but it is giving same error Method or data member not found and not proceeding further.

Sincerely, i m new to Access & VB i am doing the coding based on a video according to my requirement of official work, so not sure why & where tags are used.

Thanks,
Naveen.
 
create an instance of Currentdb

dim db as dao.database

set db = currentdb
db.execute "yourSQL"
 

Users who are viewing this thread

Back
Top Bottom