Queries :: Update And Insert Records With SQL Statements Using Access 2010

Jul 10, 2014

I am trying to update and insert records with SQL statements. Below my code:

Select Case FirstGRV
Case "Y"
sql = "UPDATE Tbl_SellingPrices " & _
"SET SellingPrice = " & Me!Text2 & ", SellingPriceDateFrom = date(), SellingPriceDateTo = #" & Me!Text3 & "#" & _
"WHERE SellingPriceStockCode = Forms!Frm_GRV!GRVStockCode and SellingPriceDateFrom =#01-01-1900#;"

[Code] ....

My problem is I need to know if the execution of the SQL statement was successful or not. I use the RecordsAffected method, but it always returns 0, no matter what.

View Replies


ADVERTISEMENT

Queries :: Update Date Entry Using SQL In Access 2010

Sep 20, 2013

I have a date field with dates stored as MM/DD/YY, ie.10/13/09 and I want to use an UPDATE statement to change the year from 09 to 2009 but keep the 10/13/. The issue I'm encountering is when I use a wildcard in the SET portion it takes that as literal and updates with the wildcard. ie. Set Date = '*2009' WHERE Date LIKE '*09' updates the column with *2009 as the entry and not 10/13/2009. How can I update my field so I end up with 10/13/2009, not *2009?

View 4 Replies View Related

General :: Generate SQL Insert Statements From MS Access

Jul 26, 2012

i need to append data that is currently in a single MS Access table into multiple MYSQL tables that have primary keys and auto_ids etc. Therefore I need to run the queries in order so that I can use the new auto_ids correctly, see below:

INSERT INTO users (username, unconfirmed_email, password, agrees_with_terms, active, created, modified)
VALUES ("46", "", unix_timestamp(now()), 0, 0, now(), now());
SET @curr_user_id = LAST_INSERT_ID();
INSERT INTO accounts (type_id, status_id, profile_name, email, match_permissions, odesk, created, modified) VALUES (3, 0, "46", "", 1, 1, now(), now());
SET @curr_account_id = LAST_INSERT_ID();
INSERT INTO accounts_users (account_id, user_id, role_id, created, modified) VALUES (@curr_account_id, @curr_user_id, 1, now(), now());

is there a way i can change a single Access append query to generate the required insert statements to do this?

View 4 Replies View Related

General :: Possible To Have Value In Excel 2010 Cell Used To Update Access 2010 Database

Apr 4, 2013

Is it possible to have a value in an excel 2010 cell be used to update an access 2010 db?

For example, if in a spreadsheet "test" cell A2=3 then in a db "test" a column "value" is 3. However, if the value in the spreadsheet changes so does the db.

View 1 Replies View Related

Modules & VBA :: Using String To Update Records - Quotes And Apostrophes In SQL Statements

Dec 4, 2014

I'm having problems with quotation marks in a sql statement. The string is an array separated by a semicolon.

120/80;70;5'6";125

this string represents patient vitals. I'm using the string to update a record. But I get hung up with the quotation mark.

I've tried: 120/80;70;5''6'"';125 which is a enclosing the quotation mark with apostrophies, but this does not seem to work. The sql still gets hung up. My sql statment looks something like:

original string: 120/80;70;5'6";125

strPreOpVits = "120/80;70;5''6'"';125"

mysql = "UPDATE mytable SET PreOpVits = '" & strPreOpVits & "' " & _
"WHERE nID = " & myRecID

docmd.runsql mysql

I've narrowed it down to the quotation marks and I'm unsure how to handle these. I get a runtime 3075 - Syntax Error.

Here is the code that I use to convert the original string

Public Function FixQuotesInSql(strToFix As String)
Dim lgth, y As Long
Dim strTemp, char2Add As Variant
'This routine fixes the use of apostrophe and quotation marks in an SQL sequence
'If the apostrophe is at the beginning or end of the string it replaces with 3 x "'" or "'''"
'If in the middle of the string then replaces with 2 x "'" or "''"

[Code] ....

View 7 Replies View Related

Insert Link To Music In Database - Access 2010

Jun 22, 2015

I am making a database of MP3 songs. I want to include a link to each song and be able to play the song from the database by clicking on the link.

View 2 Replies View Related

Queries :: Missing Operator Error In Multiple Update Statements

Jun 22, 2015

I'm trying to run about 300 update statements and keep getting a syntax error of missing operator... what could be wrong?

UPDATE Applicants set [NBCC ID] = '351174' where SSN = '136861387'
UPDATE Applicants set [NBCC ID] = '350960' where SSN = '138885740'
UPDATE Applicants set [NBCC ID] = '350817' where SSN = '140082154'
UPDATE Applicants set [NBCC ID] = '351013' where SSN = '145766662'

View 11 Replies View Related

INSERT SELECT Statements

Mar 1, 2007

I was wondering if you can an INSERT SELECT statement for 2 tables w/ different data source?

Like one's from Oracle and the other's from Access?

Please help :D

View 4 Replies View Related

Noob Insert/update/delete Queries

Dec 2, 2007

Hi guys,

I was wondering if someone could help? I am using Access 2002 and I am struggling to find out out how you can insert/update/delete records through a form using the design view. Is this possible or do you need to do this another way?

Could some one point me in the direction of a comprehensive tutorial or outline some instructions for what I need to do?


I need to create a form that inserts people's details into a table



When user types in a surname as a parameter query, up pops the form with the details of the person stored in the database, and the user can update the details through the form and the details are saved to the table they came from.



Thanks in advance!

View 9 Replies View Related

Queries :: Update Or Insert / Append Record In Database

Jun 5, 2013

I have two tables "TABLEA" and "TEMP"

fields in both tables are
Cust ID (Primary key)
Cust Name
Address
Cheque No
Amount
Location
Zone

I need query when i click on command button on form

if "Cust ID" which is primary key in "TEMP" Table match with "Cust ID" from "TABLEA"

It will update the record in "TABLEA" if not then append the record

View 1 Replies View Related

Help! Need An Access Guru UPDATE/INSERT INTO

Mar 11, 2005

I have an asp.net application where the user can add a new client name and password to a database, but I want to do a check to make sure that client name is not already in there. I was working with and INSERT INTO statement this here:

INSERT INTO [clients] ([clientName], [passWord]) VALUES (@clientName, @passWord) WHERE NOT EXISTS (SELECT [clients].[clientName] FROM [clients] WHERE [clients].[clientName] = clientName)

But I guess you can't use a WHERE clause with an INSERT statement.. So I am trying to use an UPDATE statement. This here:

UPDATE clients SET clientName = @clientName, passWord = @passWord WHERE NOT EXISTS (SELECT [clients].[clientName] FROM [clients] WHERE [clients].[clientName] = @test)

When I run it in access, it doesnt add a new row if I try to add a client name that is already in there, but if I try to add one that isn't it tells me it's going to UPDATE 13 rows which would be all the rows in there. Anybody have any ideas how I can do this?

View 2 Replies View Related

Forms :: Access 2010 Auto Update Calculated Date Field?

Jan 21, 2015

I have a database to track temporary decertification's. I have the expiration and max dates calculated out from the original dates at the top of each box. The temp expiration date is calculated by adding 267 days from the first date . When we enter an extension, the new expiration date is 30 days from the extension date. My question is, how can I make the expiration date update when a new extension is put in.

For ex.

Temp Decert Date: 05 Dec 2014
Temp Decert Extens 1:
Temp Decert Extens 2:
Temp Decert Extens 3:
Temp Experation Date: 31 Aug 2015
Max Temp Date: 04 Dec 2015

how can I make the expiration date update to go 30 days from what is in the extens field 1, 2, and 3 (respectively) instead of 267 days from the original date?

So I want it to look like this after updating a field

Temp Decert Date: 05 Dec 2014
Temp Decert Extens 1: 30 Aug 2015
Temp Decert Extens 2:
Temp Decert Extens 3:
Temp Experation Date: 29 Sep 2015
Max Temp Date: 04 Dec 2015

View 14 Replies View Related

General :: Update Preformatted Excel Spreadsheet With Access 2010 Query?

Jun 10, 2013

I have an Access crosstab query that I have exported to an Excel Spreadsheet. I have the spreadsheet formatted using conditional formatting and I'd rather not have to reset it every morning. It's a single spreadsheet (the columns/rows will not deviate greatly day to day) and should be very simple, but I'm not getting it for some reason.

So if I have "Test.accdb" and it contains "qryX" as my crosstab and "Sheet1.xls" is my formatted Excel spreadsheet, how do I code for the latest "QryX" to go in and replace the old "QryX" data in "Sheet1.xls" ?

View 2 Replies View Related

Access 2010 - Getting Form To Show Update Data To A Table When Two Tables Referenced

Jun 27, 2012

I have a form with two tables referenced. I am using the form only to update one of the tables. I am using the other table to pull a reference field. When I add my second table using the query builder, it makes it to where I can't edit/add in my form. I assume its because of the SQL insert statement, but I don't see this statement and can't find where it is to edit it. How to have the form only update one of the tables, while just using the second table as a reference for a field?

View 1 Replies View Related

Queries :: MS Access 2010 - Export Queries Into One Workbook But Different Worksheet

Jul 16, 2013

I have three Queries and I need to export three queries into one workbook but different worksheet,

Currently I am using ExportWithFormatting , but the result came out is three different workbook .

Is there any way I can export to one workbook ?

View 3 Replies View Related

MS Access Runs Slowly For Client PC's After A Update Or Insert.

Jan 29, 2007

Hi,

We are using MS Access as the backend to our application which has been written in delphi and have run into a problem that we have not been able to solve. Hoping someone has run into this before or any suggestions are much appreciated.

The problem:

MS Access runs slowly for client PC's after a update or insert.

- I am using ADO to connect to the Access database, which is using the OLEDB for ODBC Provider.
- The application I have sends queries (both select and update) direct to the database (ie client datasets are used).
- When only select queries are sent to the DB the response time is fine.
- When an update or insert query is sent to the DB the response time of the PC it is run on is fine.
- When an update or insert query is sent to the DB the response time of any other client PCs running the application take about 5 to 6 times longer to run queries than before the updateinsert query was done. This is the issue that I am having.
- Any client PC's that display this slower response time, can have their response time returned to normal by closing down the application and restarting it.
- No more than 3 PC's connected at one time to the DB.
- Maximum database size of 150MB.
- Problem occurs on various network setups, including domain and workgroup.
- Problem only surfaces for users at times well after any application updates have been applied (ie several weeks after, and then once the problem starts it continues).
- It does not occur for all user sites.

I have tried and thoroughly tested the following to no avail...
- Applied all the latest microsoft updates
- Closing and re-opening the ADO connection after updatesinserts
- Changed the ADO provider to Jet 4
- Saving the DB in Access 2000 or 2002 format
- Set the Default record locking to 'No Locks' and 'All records' and 'Edited record'
- Used 'Open databases using record-level locking' selected and unselected
- Many application techniques (using delphi) to work around the issue. Many of which have indeed improved general response times, but have not resolved this particular issue.

The only thing I have tried that has resolved the issue is... - Upsizing the database to SQL Server (Unfortunately this option is not a viable one for us at this stage, so I need to find a resolution to it while still using the Access DB).

Thanks for your help

View 1 Replies View Related

Queries :: Access 2007 / 2010 - Combining Two Queries Into One?

Jan 24, 2014

I have two queries, one base upon the other. I would like to combine them (If Possible) into one query so I can embed them into a form or report. I have tried without success at finding the answer on the forum as well as searching the web.

The table lists employee numbers and dates they worked. I need a count of how many employees worked each year, based upon the paycheck date, not the actual date worked. Pay check dates are two weeks apart. An extreme example, is the first pay check date of 2010 was on 1/1/2010, but all the days worked were in 2009, this would have to be included in 2010 not 2009(See the query for further date calculation understanding). Anyway, the date calculations are not the issue here.

I only have one table, so if I am not mistaken, I can't use the WHERE (SELECT... JOIN) feature. I also was unsuccessful at using SQL DISTINCT.

I am running ACCESS 2010 Tables are ACCESS 2007.

OS is Windows 7 Ultimate.

I have included a same database with the queries. qryEmployeesAnually2 is the results I am trying to achieve.

View 7 Replies View Related

Modules & VBA :: MS Access 2010 String Records Of Two Tables

Feb 14, 2014

I have two tables linked via Project ID as shown in the attached file. I need Module to concatenate Project sub types against Project Types.

View 3 Replies View Related

General :: Access 2010 - Email Records In Body From Table

Oct 1, 2013

I've set up a piece of VBA code to loop through and email various recipients data, in the form of records within the email body. This works fine, but occasionally produces an error whereby the email output body lines are duplicated spuriously. This only seems to happen when running a large number of email loops.

The data source for the email body content is a table, which for each 'loop' is refreshed with new data by 1) deleting records from that table, and then 2) appending data to the table.

The portion of code for the loop & email:

Do
'Build outputbodytext
DoCmd.OpenQuery ("EmailQ2")
DoCmd.OpenQuery ("EmailQ1")
'set up email
Set rec2 = CurrentDb.OpenRecordset("outputbodytext")
strSendTo = rec2("Email")

[Code] .....

View 3 Replies View Related

General :: Access 2010 / Adding Reports To Records As Attachments?

Apr 12, 2013

I have an Access 2010 database connected to several SharePoint lists. I'd like to be able to print a report (based on a query) and add that report as a .pdf attachment to the record I was looking at when I generated the report.

At the moment I can save the report as a .pdf to a local file store, then upload it as an attachment, but is there any way to skip that step and add it to the correct record automatically?

View 3 Replies View Related

Forms :: How To Scroll Through Records In Access 2010 With Mouse Wheel

Mar 6, 2015

I want to scroll through records in Access 2010 forms with the mouse scroll wheel.

View 10 Replies View Related

Access 2010 - Pulling TOP / Max Number Of Records User Prompted For Value

Oct 23, 2013

I would like a user to specify the total number of records they need from a query result. The result must be random, therefore cannot filter on any field or data in the table.

On a form, the user enters the total # of records they need and selects a button that executes this:

DoCmd.RunSQL.SELECT DcountRDP.RDP_IND, DcountRDP.GRP_ST_CD, DcountRDP.AUDIT_STATUS, DcountRDP.AUDIT_TYPE, DcountRDP.AUD_ID, DcountRDP.ACURT_IND, DcountRDP.AUD_DT
FROM DcountRDP
WHERE DcountRDP.MaxRecords = [Forms]![Open_Frm]![IL]

This is not working at all.

How can I make it possible for the user to enter a total needed or be prompted to enter a total and then randomly produce the first top # of records that they specify?

View 1 Replies View Related

Insert Records Into Access

Sep 6, 2004

hello,

I am trying to get a form to insert info into a access database. I am using dreamweaver 2004, i created the form with 4 text fields and a submit button. Ive added a ODBC connection and dreamweaver can qurery my table.

I added an insert record server behaviour, and i figured dreamweaver does all the work for you but when i saved and uploaded the page to my test server it would not submit and redirect to my chosen page, it only refresh the form.

Has anyone out there done this before and can notice a step that im missing.

Do i need to setup a recordset? because ive tried that as well and no success

help is much appreciated.

View 2 Replies View Related

Tables :: Merge Duplicate / Similar Records Into 1 Record In Access 2010

Jun 9, 2014

Is there a way to merge duplicate/similar Access 2010 records into one record?

I have an Access table with 1,000 duplicate records, although they are similar and not exact duplicates. As you can see below, some records contain information that other records do not. Yet, the primary key is the same for all duplicate records. I want to find a way to merge data from filled cells of duplicate records into empty cells for each duplicate record. I do not want to concatenate the data (i.e. combine last and first name, etc.). I only want to fill empty cells if there is a match for it in a duplicate record. I will delete the newly exact duplicate records later. Short of correcting the records by hand.

Example

Code:
LastName FirstName SSN Address Phone Email
Doe John 123-45-7891 123 Anywhere St. NULL john(at)gmail.com
Doe John 123-45-7891 NULL (123)456-7890 NULL

Desired Result

Code:
LastName FirstName SSN Address Phone Email
Doe John 123-45-7891 123 Anywhere St. (123)456-7890 john(at)gmail.com
Doe John 123-45-7891 123 Anywhere St. (123)456-7890 john(at)gmail.com

View 2 Replies View Related

Is Access 2010 Performance Based On Records In A Table Or File Size

Jun 29, 2014

I have an Access 2010 database .. and will be adding about 25,000 records a day to it. So it will get pretty big fast .. so 9 million a year. Is this too big for Access ?? Or is it more a issue of file size .. I know that Access 2010 can go up to 2 GB. I am interested in how I can maximize my performance and not have the database.The data is as follows .. One table. The other tables will be small, just this one will increase in size really.

Id .. Autonumber (primary key)
When .. datetime
Radio .. integer (indexed .. w duplicates)
Group .. integer (indexed .. w duplicates)
Type .. text 4
TransType .. text 2

I am considering a purge of old records if needed .. like only keeping the most previous 5 million records or some reasonable number. Like .. then I would think I should try to number my records backwards (using long int rather than autonumber and number records backwards on import) .. ie record 1 would be the most recent one and only keep the last X number of them for performance reasons.

View 8 Replies View Related

Insert Records Into Database Using Access And Asp

Feb 24, 2008

Hi, i quite new to programming.
I want to insert some values into the database.

This is my sql statement written in the asp page
Code:SQL= "INSERT INTO Login ([User], Pass,Info,GroupID,UserRootFolder,Email,IsDisabled, IsGroupAdmin,LanguageFile,AccountExpires) VALUES ('"& str_name & "','" & str_password & "','" & str_aboutUser & "'," 5 , &"''"&", '"& str_email & "', " 0 , 0 , english.dat, NULL)

The values 5, 0 , 0 and english.dat are the values i want to imput into the database. They are not variables. The rest will be variables.

This is the error i get

Code:Error Type:Microsoft VBScript compilation (0x800A0401)Expected end of statement/temasek/register_action.asp, line 12, column 200SQL= "INSERT INTO Login ([User], Pass,Info,GroupID,UserRootFolder,Email,IsDisabled, IsGroupAdmin,LanguageFile,AccountExpires) VALUES ('"& str_name & "','" & str_password & "','" & str_aboutUser & "'," 5 , &"''"&", '"& str_email & "', " 0 , 0 , english.dat, NULL)-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------^

How do i write my sql statement

Thanks

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved