473,396 Members | 1,990 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,396 software developers and data experts.

Difficulties in forming Update statement in VBA

22
I would like to update the table, tblname, to take in other columns and data from the ReportTracker Table so I created the following code:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command31_Click()
  2. 'add Report Tracker info into Sheet#
  3.    Dim strSql1 As String
  4.    Dim tblname As String
  5.    Dim MyValue As Integer
  6.    MyValue = InputBox("Enter Table #", "MyInputbox")
  7.    tblname = "Sheet" & MyValue
  8.    strSql1 = "UPDATE [" & tblname & "] SET REPO_NUM = MyValue FROM ReportTracker.Report_Num, Report.Tracker.[Repo_Name], ReportTracker.[Facility_Name] WHERE MyValue = ReportTracker.Report_Num"
  9.    DoCmd.RunSQL strSql1
  10. End Sub
There seems to be an error in the UPDATE statement.

Thanks,
Carl
Mar 29 '12 #1
2 1341
Stewart Ross
2,545 Expert Mod 2GB
Hi Carl. I have split this into a new question following on from this thread.

You are confusing the syntax of the update statement, with FROM introduced where it is not necessary amongst other things. You have not implemented what I mentioned in my last post in the previous thread, that you need to include the value of variable MyValue - you cannot reference the variable by name in the SQL string.

Could you explain your requirements clearly, telling us what fields you wish to update and to what values?

-Stewart
Mar 29 '12 #2
Carl23
22
FYI, I am a pharmacy consultant to nursing homes and am actually using Access to import my reports that are generated in Excell to separate out the physician comments in a separate report. What I am trying to do is automate the process so the user can enter a minimal amount of information. That is why I am tring to import my Excel files as Sheet1, Sheet2 and not call them by their Excel file name ie Name of Facility, Name of Unit and Date...

So what I have come up with is a ReportTracker Table in Access that keeps track of the Report_Date1, Report_Date2, Report_Date3 since we may visit a unit more than once a month, a default populated Facility_Name (each nursing home has there own Access file since we may write over 100 reports in the larger homes, the nursing unit and the field that tracks the Sheet #, Report_Number.

The other tables are imported from Access. As, I mentioned I am calling them Sheet1, Sheet2,etc. Their fields are Resident, Physician, Comment, Physician_Comment, and REPO_NUM. The Join can be made between the tables using REPO_NUM and ReportTracker.Report_Num.

Once the tables (Sheet1, Sheet2, etc) are appended, I plan to use the table to use them as a record source in each nursing units monthly report.

Thanks,
Carl
Mar 29 '12 #3

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

Similar topics

3
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: ...
8
by: pb648174 | last post by:
I have a single update statement that updates the same column multiple times in the same update statement. Basically i have a column that looks like .1.2.3.4. which are id references that need to...
2
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...
6
by: HeadScratcher | last post by:
I am trying to speed up my update statements by removing inner select statements. Example: update orders set shipname = (select contactName from customers where customerid = orders.customerID)...
5
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 ...
1
by: amitbadgi | last post by:
HI i am getting the foll error while conv an asp application to asp.net Exception Details: System.Runtime.InteropServices.COMException: Syntax error in UPDATE statement. Source Error: Line...
6
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 ...
19
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...
3
by: Antonio | last post by:
Can somebody tell my why the following procedure changes the data in the fields being updated to all the records in the database? private void updateRow(object source,...
2
by: travhale | last post by:
in a new project using .net 2005, c#. getting err message "Update requires a valid UpdateCommand when passed DataRow collection with modified rows." source RDBMS is oracle 8i. I add a new...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...

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.