473,480 Members | 1,585 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

About Update statement with table variable

10 New Member
Hi all

I have problem using table variable in update statement.
Please see below.

mpyemp="febpyemp" && this file name will change everymonth

in my update statement

Expand|Select|Wrap|Line Numbers
  1. DoCmd.RunSQL "update pyemp INNER JOIN {Mpyemp} 
  2.   ON  (pyemp.PASS={Mpyemp}.PASS) 
  3.   AND (pyemp.SSN=@tpyemp.SSN) 
  4.   SET pyemp.budrc = {Mypemp}.budrc 
  5.   WHERE (IsNull(pyemp.BUDRC)) Or (pyemp.BUDRC) = '0000';"
when I run the program. the error shown as below

run-time error 3144

Syntax Error in update statement. So someone please let me know the right statement using Mpyemp variable.
Thank you in advanced
Moe
Apr 22 '11 #1
4 3042
Rabbit
12,516 Recognized Expert Moderator MVP
strSQL = "SELECT * FROM " & tableVariable & ";"
Apr 22 '11 #2
moepusu
10 New Member
Still problem with following command

DoCmd.RunSQL "update pyemp INNER JOIN " & MPYEMP & " ON (pyemp.PASS="&mpyemp&".PASS) AND (pyemp.SSN="&mpyemp&".SSN) SET pyemp.budrc = "&mypemp&".budrc WHERE (IsNull(pyemp.BUDRC)) Or (pyemp.BUDRC) = '0000';"
Apr 22 '11 #3
TheSmileyCoder
2,322 Recognized Expert Moderator Top Contributor
I can't say if you directly copy/pasted your code, but the spaces between the & are important, and they seem to be missing from your code.

Expand|Select|Wrap|Line Numbers
  1. DoCmd.RunSQL "update pyemp 
  2.   INNER JOIN " & MPYEMP & " 
  3.   ON (pyemp.PASS=" & mpyemp & ".PASS)
  4.   AND (pyemp.SSN=" & mpyemp & ".SSN) 
  5.   SET pyemp.budrc = " & mypemp & ".budrc 
  6.   WHERE (IsNull(pyemp.BUDRC)) Or (pyemp.BUDRC) = '0000';"
If this doesn't work, I would suggest you start by forming your SQL string into a string variable, and then post that variable into a msgbox so that you can "proofread" it.
Apr 22 '11 #4
moepusu
10 New Member
TheSmileyCoder

Thank you so much for your help
It works well.
Apr 25 '11 #5

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

Similar topics

3
6210
by: Robert Mark Bram | last post by:
Hi All! I have the following two methods in an asp/jscript page - my problem is that without the update statement there is no error, but with the update statement I get the following error: ...
9
4554
by: Muzamil | last post by:
hi For an unavoidable reason, I have to use row-by-row processing (update) on a temporary table to update a history table every day. I have around 60,000 records in temporary table and about 2...
8
3160
by: Perre Van Wilrijk | last post by:
Hello, I have 2 ways of updating data I'm using often 1) via a cursor on TABLE1 update fields in TABLE2 2) via an some of variables ... SELECT @var1=FLD1, @var2=FLD2 FROM TABLE1 WHERE...
2
2500
by: serge | last post by:
/* This is a long post. You can paste the whole message in the SQL Query Analyzer. I have a scenario where there are records with values pointing to wrong records and I need to fix them using an...
9
2907
by: Vorpal | last post by:
Here is a small sample of data from a table of about 500 rows (Using MSSqlserver 2000) EntryTime Speed Gross Net ------------------ ----- ----- 21:09:13.310 0 0 0 21:09:19.370 9000 ...
5
9811
by: Wing | last post by:
Hi all, I am writing a function that can change the value "Quantity" in the selected row of MS SQL table "shoppingCart", my code is showing below ...
6
2676
by: FayeC | last post by:
I really need help figuring this out. i have a db with mostly text fields but 2. The user_id field is an autonumber (key) and the user_newsletter is a number (1 and 0) field meaning 1 yes the ...
5
2572
by: devi | last post by:
hi, I am creating a simple bug tracker application (in Access db) and i created a hisotry table to log the bug history. The history table contains details like ProblemRecordNo (PRN),...
19
8338
by: Steve | last post by:
ASP error number 13 - Type mismatch with SELECT...FOR UPDATE statement I got ASP error number 13 when I use the SELECT...FOR UPDATE statement as below. However, if I use SELECT statement without...
5
4266
by: HughManity | last post by:
I found this example, and I'm curious as to what the WHERE EXISTS part of it does - it seems to simply repeat what was stated before. How would functionality differ if it were left off? UPDATE...
0
7044
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6908
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7045
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6741
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5341
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4782
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
4483
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
2995
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
182
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.