473,320 Members | 1,900 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Runtime error "invalid Operation" 3219

Hi Friends,

I am a newbie in MS ACCESS. I am using A2010 Version. What I am expecting my code to do is: Compare the field of the table and update other field in the same row.

My code will make sense better htan words :)

Expand|Select|Wrap|Line Numbers
  1. Dim zDB As DAO.Database
  2.      Dim zRS As DAO.Recordset
  3.      Dim zSQL As String
  4.      '
  5.      zSQL = "UPDATE AddUser SET [Password]='" & Pwd & "' WHERE AddUser.EmployeeId='" & User & "';"
  6.  
  7.      '
  8.      'See here is where I set the pointer to the current
  9.      'database only once
  10.      Set zDB = CurrentDb
  11.      '
  12.      'using recordsets...
  13.     Set zRS = zDB.OpenRecordset(zSQL, dbOpenSnapshot)  'getting ERROR in this line
  14.      '
  15.      '
  16.      zRS.close
  17.      If Not zRS Is Nothing Then Set zRS = Nothing
  18.      If Not zDB Is Nothing Then Set zDB = Nothing
  19.  
  20.  
Need urgent help. Please provide valuable feedback.
May 13 '15 #1

✓ answered by Seth Schrock

"Note: EmployeeId is an Primary Key with Numeric datatype"

This is the key to your problem. You are passing the User as a string because of the single quotes. Make your zSQL variable WHERE clause be the following.
Expand|Select|Wrap|Line Numbers
  1. WHERE AddUser.EmployeeId=" & User & ";"

6 3485
Seth Schrock
2,965 Expert 2GB
The OpenRecordset method can't be used on UPDATE queries as it doesn't return any records. Instead you would do the following.
Expand|Select|Wrap|Line Numbers
  1. zDB.Execute zSQL, dbFailOnError
You can get rid of the zRS declaration in line 2 and all other lines that reference it.
May 13 '15 #2
Thank you so much for your reply.

System is still throwing an error after I made the provided changes.

ERROR: 128
Datatype mismatch

Note: EmployeeId is an Primary Key with Numeric datatype

Have a look to the code:

Expand|Select|Wrap|Line Numbers
  1. Dim zDB As DAO.Database
  2.   '  Dim zRS As DAO.Recordset
  3.      Dim zSQL As String
  4.  
  5. Set zDB = CurrentDb
  6. zSQL = "UPDATE AddUser SET [Password]='" & Pwd & "' WHERE AddUser.EmployeeId='" & User & "';"
  7.      zDB.Execute zSQL, dbFailOnError
  8.  
  9.     ' zRS.close
  10.     ' If Not zRS Is Nothing Then Set zRS = Nothing
  11.      If Not zDB Is Nothing Then Set zDB = Nothing
  12.  
Please provide your feedback.
May 13 '15 #3
Seth Schrock
2,965 Expert 2GB
"Note: EmployeeId is an Primary Key with Numeric datatype"

This is the key to your problem. You are passing the User as a string because of the single quotes. Make your zSQL variable WHERE clause be the following.
Expand|Select|Wrap|Line Numbers
  1. WHERE AddUser.EmployeeId=" & User & ";"
May 13 '15 #4
zmbd
5,501 Expert Mod 4TB
To provide context: Check for existing EmployeeId in the table and then update password in same table- post#8
(I also answered the reason for Error-3219 in this post :) )
May 13 '15 #5
Oh. Small mistake lead me in trouble :P

Thank you so much seth. I am really thankful for solving my problem. :D
May 14 '15 #6
Thank you zmdb for your wonderful help . :)
May 14 '15 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Bob Bamberg | last post by:
Hello All, I have been trying without luck to get some information on debugging the Runtime Error R6025 - Pure Virtual Function Call. I am working in C++ and have only one class that is derived...
7
by: wmkew | last post by:
Hello everyone I'm encountering a R6002 Runtime error and several bugs when trying to generate a simple Managed C++ application with .NET 2003. The main problem seems to arise from linking with...
7
by: Yongsub Eric Shin | last post by:
Hi. I'm just a beginner in ASP.Net. I started writing codes and I keep on getting this Runtime Error page, where it says "Description: An application error occurred on the server. The current...
7
by: yuanlinjiang | last post by:
I am working on converting a win32 console application from VC6 to VC7. My version is Microsoft Development Environment 2003 version 7.1.3088. The code works fine on VC6. it is a console...
2
by: Aleksandar | last post by:
Hi, I need to convert set of Java classes exported from IBM Modeling environment to C# for implementation. When I invoke JCLA conversion from File->Open->Convert in Visual Studio 2005 it starts...
8
by: g_man | last post by:
I am trying trap Runtime error 3022 (duplicates) in the click event of a command button that closes the form. I have code in the Form_Error event that does a good job of providing a more meaningful...
7
by: John | last post by:
Hi Everyone, I'm having this extremely annoying problem with Internet Explorer 6, giving me an error message saying "unknown runtime error" whenever I try to alter the contents of a <divelement...
3
by: Jim Armstrong | last post by:
Hello all - This is driving me crazy. I have a table called tblClients - very simple, has the following fields: taxID (PK) ClientName SalesName The main form of my application allows a...
2
by: blogman | last post by:
I am getting a Visual studio 2008 IDE application R6034 runtime error. This means that the IDE application is raising the error not the application I am building. This means that Microsoft did not...
1
by: abhijaiswal | last post by:
Hi All, I am working on a project where I used to views (view1 and view2). I set my first page as view2. I have around 10 Textboxes, 5 dropdown, 4 List view and 6 buttons. When I run my web...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.