Error When Trying To Insert String With Apostrophe

Apr 27, 2005

Hey, I have a problem with my application......when the user trying to insert string with apostrophe into txtDesc (text box), the code returns error...

Run-time error '3057'

the database inserts any records excellently, but not with the apostrophe....

here is my code:
Code:sql = "INSERT INTO M_Stock ([StockRef], [StockGroup], [Desc], [Location], [Category], [UOM], " & _ "[RQ], [Remark0], [Remark1], [Remark2]) " & _ "VALUES ('" & txtStockRef & "', '" & cmbSG & "', '" & txtDesc & "', '" & cmbLoc & "', " & _ "'" & cmbCat & "', '" & cmbUOM & "', '" & txtRQ & "', '" & txtRemark0 & "', " & _ "'" & txtRemark1 & "', '" & txtRemark2 & "');"Set dbs = CurrentDbdbs.Execute sql

Can someone help me with this problem? Thanks in advance

View Replies


ADVERTISEMENT

Insert Error Due To Apostrophe - Syntax Needed

Jul 20, 2006

hi,
i am getting an error in my coding for a INSERT statement becasue the text of the field contain an apostrophe.

that is my code is

DoCmd.RunSQL "INSERT INTO tbl_StartEndDates_OVERHEAD ( Last_Name)" _ & "VALUES ('" & Forms!OverheadEmployeeDates!lblLast_Name & "');"

but the text in Forms!OverheadEmployeeDates!lblLast_Name is "D'Amereo".

I know that this works for all other Last_Names without an apostrophe in it

does any one know the correct coding for this?

thansk
tuk

View 3 Replies View Related

Apostrophe In Target Db Name Throws Error

Dec 14, 2007

sql = "SELECT Table1.* INTO Table1 IN '" & sExpFileName & "' FROM Table1"
CustDB.Execute sql

where the sExpFileName contains the path of The Target MS Access DB
The Query works fine. But recently I discovered that if my target File name contains apostrophe It gives error as Query Input must contain at least one table or query

Is there any way to solve this problem. Please suggest me some way

View 7 Replies View Related

Queries :: Syntax Error When Name Contain Apostrophe

Mar 3, 2014

I have a query written in Visual Basic as follows

UA1 = Forms(ParName).Form.NOM
UA2 = Forms(ParName).Form.PRENOM
UA3 = Forms(ParName).Form.CARTE
Forms(ForName).Recordset.FindFirst "[NOM] = '" & UA1 & "'" & " And " & _
"[PRENOM] = '" & UA2 & "'" & " And " & _
"[CARTE] = '" & UAE & "'"

This query works and I can spot the record based on 3 fields and display it. Now I have discovered that we have a person who has an apostrophe in his name like O'Brian. The above code gives a syntax error in this case.

View 3 Replies View Related

Multiple INSERT String

Aug 4, 2005

Can anyone help?

Have searched the net with no luck. This is my problem.

I am trying to use a multiple INSERT string to create records in a table, from a VB application and using ADO to do it.

If I send the single INSERT it works fine, but if I try to send more than one in the same string I get a 'MISSING SEMI COLON AT END OF STATEMENT' error.

I have tried putting one at the end of each statement, then just at the end of the INSERT statements string, but still get this error.

Can Access actually handle more than one SQL instruction at a time?

Thanks for any help.

View 3 Replies View Related

AutoNumber Field And SQL String INSERT INTO Statement

Apr 4, 2008

In my statment below the ID is an autonumber. I placed it in the first part ofthe SQL string..but not where I have to variables referenced...

I have to add it to the SQL statement...Its not a varible although I can make it one by getting the largest number nad adding one...
Do I have to make it a non-autonumber and do it like I said above

Or is there another way to treat the autonumber (ID) in the SQL INSERT INTO statement...

THanks




Code:MySQL = "INSERT INTO dbo_data ("MySQL = MySQL & "ID,Name,Owners_Residence,Notice_Expiration,Notes,N otice_Number,Status,Notice_Date,Property_Address,N uisance_Type,Addition_Name,Range,Lot,Block,Zip_Cod e,Display_PID,Sec_tion,Township,Property_City,Prop erty_State,Property_Zip"MySQL = MySQL & ") values ("MySQL = MySQL & "'" & varName & "','" & varOwners_Residence & "','" & varNotice_Expiration & "','" & varNotes & "','" & varNotice_Number & "','" & varStatus & "','" & varNotice_Date & "','" & varProperty_Address & "','" & varNuisance_Type & "','" & varAddition_Name & "','" & varRange & "','" & varLot & "','" & varBlock & "','" & varProperty_Zip & "','" & varDisplay_PID & "','" & varSec_tion & "','" & varTownship & "','" & varProperty_City & "','" & varProperty_State & "','" & varZip_Code & "'"MySQL = MySQL & ");"

View 14 Replies View Related

Modules & VBA :: Insert CR / LF In Memo Field Based On Search String

Jan 16, 2014

I import a CSV field which has not preserved the CR/LF when it was exported from BCM Remedy. There is no setting for that. The memo field prints on my report like this:

A custom solution would be developed, that once implemented, could become the standard product in similar situation. Normally would assign to Network Engineering, but will work with Ray and the IPT Team to cost out the solution and get approval to proceed. 2012/05/24 10:44:28 AM PCOLLINS Sent to Ray Massie for review to determine if a solution needs to be proposed, or if they can wait for the National IPT solution to be ready in 2013.

I want to add VBA code that inserts a CR/LF in the memo field before all but the first occurance of a string that looks like a date, the first occurance doesn't need it. I will do it right after I import the CSV file into the table, so it happens only once, and it always prints and displays the CR/LF.

The memo field is called "NBS Update" and the table is called "CCRR Remedy Data"Here is what I have, but don't actually know what to put in to find the date and add a CR/LF:

Code:
Dim db As DAO.Database

Code:
Dim db As DAO.Recordset
Dim srtSQL As String

[code]...

View 14 Replies View Related

Apostrophe

Nov 2, 2004

For example, if I'm coding an insert manually, if I need to insert a string from a textbox, I have to do something like this

mycn.execute "Insert into Test(FName,LName)values('" & me.text1 & "','" & me.text2 & "')

I have to put a ' at the end of each string values

Is there any way to bypass this? I mean I could put a validation code and each time I detect an apostrophe I handle it so that it doesn't create a problem

But I mean a simple way to bypass this

View 2 Replies View Related

INSERT INTO Error

Nov 2, 2006

Hi Forum,

I am working on a little database and I have the code shown below. When I run it, I get the following error message:
Syntax error in query. Incomplete query clause.

Here is the code:

Dim cpyText As String
Dim sqlStatement As String
Dim newName As String

cpyText = List11.Column(0, List11.ListIndex)
fld_lname.SetFocus
newName = fld_lname.Text

sqlStatement = "INSERT INTO '" & newName & "' ([perm]) VALUES ('" & cpyText & "')"
DoCmd.RunSQL (sqlStatement)

The sql statement is on one line...it just wrapped in this window.
In the debug window, the values of the variables in the sqlStatement are what I expect them to be. So I cannot figure out why I am getting the error.

Any assistance is greatly appreciated.
Mike

View 2 Replies View Related

Alphabetizing - With An Apostrophe

Apr 2, 2005

Hi, I may be dense, but I cannot find an answer to this question anywhere. If it has a simple and obvious answer, my apologies.

I have created an index with a field called "Surname" -- I need to know how to force Access to alphabetize the names disregarding the apostrophes (or a space) - for example, O'Brien. The way it works now, all the O' (s) go at the beginning of the Os (O'Brien, O'Malley, O'Neal, Oakley). I want it to go - Oakley, O'Brien, Oddfellow, O'Malley.

Is there a way to do this and still display the apostrope? I feel that I could set something for the field in the design view, but for the life of me I can't figure it out.

Thanks in advance for any help. :)
Jeri

View 1 Replies View Related

INSERT INTO Syntax Error ???

Oct 30, 2005

Hello All,
I'm am writing an App in Java connecting to an MS Access database. I am now getting a syntax error on the following insert into statement:

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
source = "jdbc:odbc:DKOperations";
connection = DriverManager.getConnection(source);
Statement stmt = connection.createStatement();
String CustInfoTable = "CUSTOMER_INFORMATION";
stmt.executeUpdate("INSERT INTO " + CustInfoTable + " CUSTOMER_FIRST_NAME VALUES " + CustFirstName);

This is the error:
An SQLException occurred: [Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement.

I cannot figure out what the syntax error is. Anyone have an insight on this for me? Most likely something easy that I am missing.


Thanks!

View 1 Replies View Related

Insert Into Syntax Error

Apr 2, 2008

Hi

This may be a very silly question but I have the following code which is meant to take data from textboxes, checkboxes etc and insert it into a new record on a table using the INSERT INTO statment. However I am getting a Syntax error in my INSERT INTO statement which i cannot figure out.

Please Help!!?

Private Sub cmdSaveRecord_Click()

Dim SQL As String
Dim Today As String
Dim Ref As String
Dim HK As String
Dim Site As String
Dim Equip As String
Dim Serial As String
Dim Invoice As String
Dim Client As String
Dim HKRef As String
Dim Tested As String
Dim Completed As String
Dim chkHKr As String
Dim Repaired As String
Dim Spares As String
Dim CompDate As String
Dim Exp As String

Today = txtDate
Ref = txtRef
HK = txtHK
Site = txtSite
Equip = txtEquipment
Serial = txtSerial
Invoice = txtInvoice
If cboClient.Column(0) <> Null Then Client = cboClient.Column(0) Else Client = ""
HKRef = txtHKRef
Tested = chkTested.Value
Completed = chkCompleted.Value
chkHKr = chkHK.Value
Repaired = chkRepaired.Value
Spares = chkSpares.Value
CompDate = cldComp.Value
Exp = cldExp.Value


SQL = "INSERT INTO ServiceReport (Date, CallReferenceNo, HongKongFaultNo, Client, Site, Equipment, SerialNo, Tested, Repaired, Spares, HK, ExpectedDate, Completed, InvoiceNo, CompletedDate VALUES (Today, Ref, HK, Site, Equip, Serial, Invoice, Client, HKRef, Tested, Completed, chkHKr, Repaired, Spares, CompDate, Exp)"

DoCmd.RunSQL SQL

View 5 Replies View Related

Insert Into ... Select Error

Nov 2, 2005

I`m trying to insert some rows of the table [Produse finite dbo_SC03XX00] into the table [Loturi dbo_SC33XX00].

So, I tryed to run the following queries:

A) INSERT INTO [Loturi dbo_SC33XX00] ( [Loturi dbo_SC33XX00].SC33001, [Loturi dbo_SC33XX00].SC33002, [Loturi dbo_SC33XX00].SC33003, [Loturi dbo_SC33XX00].SC33005)
VALUES (select [Produse finite dbo_SC03XX00].SC03001,'01','000000000999',5000 from [Produse finite dbo_SC03XX00]);

But, when I want to save the query I get the following error:

"Syntax error. in query expression 'select [Produse finite dbo_SC03XX00].SC03001'"

B) INSERT INTO [Loturi dbo_SC33XX00] ( [Loturi dbo_SC33XX00].SC33001, [Loturi dbo_SC33XX00].SC33002, [Loturi dbo_SC33XX00].SC33003, [Loturi dbo_SC33XX00].SC33005)
VALUES select [Produse finite dbo_SC03XX00].SC03001,'01','000000000999',5000 from [Produse finite dbo_SC03XX00];

and I get the error:

"Syntax error in INSERT INTO statement."

I thought that the select query might be wrong, so I tested it:

"select [Produse finite dbo_SC03XX00].SC03001,'01','000000000999',5000 from [Produse finite dbo_SC03XX00]"

and it runs correctly.

How can I solve the problem? How can I insert the specified rows from the table [Produse finite dbo_SC03XX00] into the table [Loturi dbo_SC33XX00]?

Thank you in advance.

View 1 Replies View Related

Error When Trying To Insert Query

Jan 9, 2007

Hi,

I was wondering if i could get some help here. I got error message saying "user defined - typed not defined" and it's highlighting the first line that is WorkBase as Database.

Here is my code.
Dim WorkBase As Database
Dim WorkRS1 As Recordset
Dim rsNew As New ADODB.Recordset

Set WorkBase = CurrentDb

strSQL = "INSERT INTO [Projects](Project_ID, [OLD J_ID]) "
strSQL = strSQL + "VALUES ('" & myProjectID & "', '" & myOldPID & "')"
WorkBase.Execute strSQL, dbFailOnError
WorkBase.Close

This is for Office 2003

Thank you in advance

View 1 Replies View Related

Insert SQL Error For Access

Sep 27, 2005

I keep getting the error Syntax Error in INSERT into statement. I don't know why

This is the sql statement:

Dim intRequest As Integer
Dim intRequest2 As Integer
Dim strSQL As String
Dim intInvoiceNumber As Integer
Dim strInvoiceDate As String
Dim strName As String
Dim intBalanceDue As Double
repeats:

If Paid.Value = -1 Then
intRequest = MsgBox("Now that you have checked this as been paid, do you wish to finalize this and become irreversable? (If you want further help about this click the Cancel button)", vbInformation + vbYesNoCancel)
If vbNo = intRequest Then
cancellation:
Paid.Value = 0
Call MsgBox("Request cancelled.", vbInformation)
Exit Sub
ElseIf vbYes = intRequest Then
' Perform action here
Invoice_Number.Enabled = True
Invoice_Number.SetFocus
intInvoiceNumber = Val(Invoice_Number.Text)
Invoice_Date.SetFocus
Invoice_Number.Enabled = False
strInvoiceDate = Invoice_Date.Text
Bill_To_Name.SetFocus
strName = Bill_To_Name.Text
strSQL = "INSERT INTO Paid-Address (Invoice-Number, Invoice-Date, Name, Balance-Due) VALUES ('" & Val(intInvoiceNumber) & "','" & strInvoiceDate & "','" & strName & "','32')"
Invoice_Number.Enabled = False
MsgBox (strSQL)
DoCmd.RunSQL strSQL
Else
intRequest2 = MsgBox("You have checked this invoice to be paid but if you don't finalize it, it be assumed an error or the cheque has bounced. If you finalize it in the other hand this invoice will be permenantly deleted from this record and entered into the paid summary instead. Do you wish to return back to the request message or do permenant cancellation?", vbInformation + vbYesNo)
If intRequest2 = vbYes Then GoTo repeats
GoTo cancellation
End If
End If

View 7 Replies View Related

Error In INSERT INTO Statemanet

Jan 8, 2006

This is my code:


<%
dim connection
dim sSQL,sConnString, cat, compname, contactname, phone1, phone2, fax, address1, address2, city, state, zip, email, website, desc

cat = (Request.Form("cat"))
CompName = (Request.Form("CompName"))
ContactName = (Request.Form("ContactName"))
Phone1 = (Request.Form("Phone1"))
Phone2 = (Request.Form("Phone2"))
Fax = (Request.Form("Fax"))
Address1 = (Request.Form("Address1"))
Address2 = (Request.Form("Address2"))
City = (Request.Form("City"))
State = (Request.Form("State"))
Zip = (Request.Form("Zip"))
Email = (Request.Form("Email"))
Website = (Request.Form("Website"))
Desc = (Request.Form("Desc"))

'declare SQL statement that will query the database
sSQL="INSERT INTO Members (cat, CompName, ContactName, Phone1, Phone2, Fax, Address1, Address2, City, State, Zip, Email, Website, Desc) VALUES ('" & cat & "',' " & CompName & "', '" & ContactName & "', '" & Phone1 & "', '" & Phone2 & "', '" & Fax & "', '" & Address1 & "', '" & Address2 & "', '" & City & "', '" & State & "', '" & Zip & "', '" & Email & "', '" & Website & "', '" & Desc & "')"

'define the connection string, specify database
' driver and the location of database
sConnString="DRIVER={Microsoft Access Driver (*.mdb)};" & _
"DBQ=" & Server.MapPath("../db/gcdb404.mdb") & ";"

'create an ADO connection object
Set connection = Server.CreateObject("ADODB.Connection")


'Open the connection to the database
connection.Open(sConnString)

'execute the SQL
connection.execute(sSQL) (LINE 37)

'check to see if there were any errors
If err.number=0 Then
response.redirect ("member_admin.asp?action=list")
End If

'close the object and free up resources
Connection.Close
Set Connection = Nothing

%>

I get this as an error:

Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement.

/gcchamber/admin/addtodb.asp, line 37

Line 37 being: connection.execute(sSQL)


I have been attempting to fix the problem for hours. Can anyone please help?

Thanks...

View 3 Replies View Related

Syntax Error-during Insert

Mar 22, 2007

This is a simple code for inserting values to database.But I'm getting syntax error in the insert statement.I'm attaching the code for reference.Do help me out
Regards
Ransha

Dim mail,Login,password,conn,strSql
Login=Request.Form("name")
password=Request.Form("password")
mail=Request.Form("email")
'Creating connection Object
Set conn=Server.CreateObject("ADODB.Connection")
conn.Open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=C:/example/login.mdb"
strSql = "INSERT INTO Names (UserName, Password, Email) VALUES ('"&Login&"','"&password&"','"&mail&"')"
conn.Execute(strSql)
conn.Close
Set conn=nothing

View 3 Replies View Related

Syntax Error Insert Into

Oct 7, 2007

Can anyone tell me what is wrong with this statement. I get the error "Syntax error in INSERT INTO statement". I am the worst kind of user as I did not write this database and am trying to learn on the fly. Any help is greatly appreciated.
This macro is supposed to insert an amount into an "Activity" record based on the Co_Default_Rate field setup in the CompanyInfo table.

INSERT INTO [FORMS]![Activity]![Amount] SELECT (CompanyInfo.Co_Default_Rate)
FROM CompanyInfo
WHERE CompanyInfo.Co_Number = [FORMS]![Installs]![Installs_Co_Number];

View 1 Replies View Related

General :: Error In Connection String

May 21, 2014

I faced this error :

Run-time error '-2147467259(80004005)

The database has been placed in a state by user 'Admin' on machine "topleveldomain' that prevents it from being opened or locked.

in vba code :
I write such as :

con.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:My ProjectBEdatabase1.accdb;"

I have used the ms access 2013.

I also have split this database such as instruction by people but nothing effect.

View 3 Replies View Related

Syntax Error In Insert Into Statement

Feb 1, 2007

What is the syntax error in this Insert Into statement ?

INSERT INTO RawData(RunID,fullName,name,category,type,subType, numberOfLines,virtual,date,namespace) SELECT 257 ,fullName,name,category,type,subType,numberOfLines ,virtual,#1/3/2007#,namespace FROM RawData WHERE namespace ='customer.demo' AND RunID =256

View 2 Replies View Related

Syntax-error In INSERT INTO-expression

Apr 13, 2005

Hello.

I've managed to create an access-database and (fill it with some data), retrieve data from it with asp, but
when I try to insert or update data with asp, I get the same error:

"Syntax-error in Insert expression" or "Syntax-error in update expression"

Do I have to "chmod" the database to write to it, or what?

(I usually work with sql-databases, and the code/syntax I believe is not wrong,as it works on another database)
Conn.Execute("INSERT INTO tour(date,venue,city,link) VALUES('" & datum & "','" & venue & "','" & city & "','" & link & "')")

Thank you in advanced for answering my query.

//Joakim

View 5 Replies View Related

Syntax Error In 'FROM' Statement For StrSQL String

Feb 7, 2006

Anybody see anything wrong the syntax for the below query. I'm trying set up this query
to pass a string to 'struser' for multiple users. I'm getting 'Syntax error in FROM
clause'. Thanks ! ! !

Dim strSQL As String
Dim struser As String
struser = "MIKE"
Set db = CurrentDb()
Set qdf = db.QueryDefs("qryUser")
strSQL = "SELECT Salable_Figures.Loan_Originator_Code," & _
"Salable_Figures.Loan_Originator_Name," & _
"Salable_Figures.Lastname_Sort," & _
"Salable_Figures.Team, Salable_Figures.Plan," & _
"Salable_Figures.Monthly_SCountOfLoan_Program_Code AS Monthly_SCount, " & _
"Salable_Figures.Monthly_SSumOfNote_Amount," & _
"Salable_Figures.Salable_Monthly_Goal," & _
"Salable_Figures.YTD_SCountOfLoan_Program_Code AS Yearly_SCount," & _
"Salable_Figures.YTD_SSumOfNote_Amount AS Yearly_SSumOfNote_Amount, " & _
"Salable_Figures.YTD_SSumOfNote_Amount AS Yearly_SSumOfNote_Amount," & _
"Salable_Figures.Yearly_Salable AS Yearly_Salable_Goal " & _
"FROM Salable_YTD_Figures INNER JOIN Salable_Figures" & _
"ON Salable_YTD_Figures.Loan_Originator_Code = Salable_Figures.Loan_Originator_Code " & _
"WHERE Salable_Figures.Loan_Originator_Code)=" & struser & _
"';'"
' Apply the new SQL statement to the query
qdf.SQL = strSQL
' Open the query
DoCmd.OpenQuery "qryUser"

View 1 Replies View Related

Error 80040e10 - No Value Given For One Or More Required Parameters In SQL String

Sep 29, 2015

I have the error 80040e10-No value given for one or more required parameter inside a SQL string and I know that the problem is some/one of my variables passed, however I cannot found the mistake. See down here my code. I got experience in VBA but no much in ACCESS so the query have some problems.

I got the following parameters used inside of the string (I can see before open the recordset that all of them have valid values);

TotalGj is a number result of a dsumTemp1 is a textMketer is a text

My code is down here

Sub Enterdata()
Dim Mketer As String, MonthBR As String
Dim HECAmount As Currency
Dim RsCustomers As ADODB.Recordset, RsFfeesMonth As ADODB.Recordset
Dim Cnx As ADODB.Connection

[Code] .....

View 5 Replies View Related

An Apostrophe Is Causing Problems While Inserting!

Mar 24, 2008

Hi,

In my database if the user wants to change a record, I make them store the old record in another table. I am using the following code.


Private Sub cmdArchive_Click()

On Error GoTo ErrorHandler
Dim conn As ADODB.Connection
Dim i As Integer
Dim s As String
Dim sSQL As String

sSQL = "INSERT INTO tblNamesArchive ( txtGivenName, txtSurname )" _
& "VALUES ( '" & txtGivenName & "', '" & txtSurname & "');"

Debug.Print sSQL
Set conn = CurrentProject.Connection
conn.Execute sSQL
GoTo ThatsIt
ErrorHandler:
Select Case Err.Number
Case -2147217908 'command text not set
Case -2147217865 'cannot find table
Case 3021 'no records
Case Else
MsgBox "Problem with cmdArchive_Click()" & vbCrLf _
& "Error " & Err.Number & ": " & Err.Description
End Select
ThatsIt:
conn.Close

End Sub


I have no problems making the following code work except if there is an apostrophe " ' " in either the txtGivenName or txtSurname . For example O'Keefe it shows an error but not O"Keefe! How do I fix this?


Thanks

Raghu Prabhu
Melbourne.

View 2 Replies View Related

Queries :: Add Apostrophe To Mixed Data?

Jan 9, 2014

I am combining fields one that has apostrophe's and the other does not. exp "if this field is null use data from this field (which does not have an apostrophe) otherwise use current field (which has apostrophe)

"red"
blue
orange
"yellow"

How can I change that in the query without changing the previous query to

"red"
"blue"
"orange"
"yellow"

View 2 Replies View Related

Find Keycode To Apostrophe / Quotation Key

Oct 28, 2014

I have a Dell keyboard at work and I am trying to find the keycode to the apostrophe/quotation key. I want to disable this when pushed with the ctrl key. I've searched online but could not find anything that shows that specific key. I only see apostrophe keys or quotation keys but not the combination of both which is what I have.

View 4 Replies View Related







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