Quotes AND Apostrophes In Combo Box -how?

Jul 25, 2005

Hello,

I have a combo box on a form that simply selects a record from a 2-table query. My problem is that the data is Book Titles, which can contain both quotes and apostrophes, sometimes in the same title. other than eliminating these characters from the records, how do I make the simple vba code for the box work for either quotes or apostrophes in a record? The box works fine as long as the record does not contain these characters. (I'm a big vba rookie by the way, and this code was created by the box wizard.)
Using Access 2003,
Here is the code for the box:

Private Sub cboSelectBook_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[BookTitle] = '" & Me![cboSelectBook] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub

TIA for any suggestions!
LMS

View Replies


ADVERTISEMENT

Modules & VBA :: How To Handle String Values Containing Apostrophes Or Quotes

Sep 2, 2014

My db contains an unlinked form that is used to append records to 1-3 separate tables (tests to see if master records exists, appends if needed, moves on to child records). One of the fields is a text field meant for notes. The VBA errors out whenever this text contains apostrophes or quotes.

Is there a simple way to recall the string field with quotes and apostrophes intact and append it, or will I have to validate and remove them from the string?

View 3 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

SQL Quotes

Jan 11, 2006

I wondered if someone could explain something for me.

In SQL the difference between ' Single Quotes and " Double Quotes and when and when not to use either.

View 4 Replies View Related

How Do You Get Rid Of Quotes

Apr 15, 2008

How do you get Rid of quotes




I have this following code:

---------------------------------------------------------
a = "MPI_CORE_DATA"

b = 'Need something here to get rid of the quotes in a

DoCmd.RunSQL "CREATE TABLE " & b
---------------------------------------------------------


How can i get rid of the quotes (") in a e.g. so "MPI_CORE_DATA" will become MPI_CORE_DATA

View 1 Replies View Related

Quotes Dam Quotes

Aug 12, 2005

I have a nice little app that works very well except that the code is not tolerant of single quotes in the user's data. My problem is that VB uses double quotes for its literals and SQL uses single quotes so where does that leave me?

The user has entered a comment into a data field and I am now adding this to the record on the database. I don't know if the user's data contains a quote. If it doesn't then all is well. If it does then, crash.

Here is a code sample...

Dim SQLStr As String, Ret As Integer
SQLStr = " UPDATE MeetingRole " _
& " SET MeetingRole.Comment = '" & [Forms]![Comment]!Text2.Value _
& "' WHERE MeetingRole.DateOfMeeting = '" & [Forms]![MeetingStatus]![List0] _
& "' ;"

CurrentDb.Execute SQLStr

Anyone know of a standard solution?

View 2 Replies View Related

Need Twp Single Quotes Somewhere

Jun 12, 2006

i have this qry field that works fine if my formulaID is a NUMBER field.

UomUsageSum: Val(Round(DSum("nz([UomUsage])","[tblFormulaDetail]","[FormulaID] = '" & [FormulaID] & " "),4))

However, i just changed the formulaID to TEXT in my table.

So I think i need different quotes somewhere at the criteria end of this qry calc because FormulaID is now TEXT.
how do i fix this at the end of the field?
thanks

View 2 Replies View Related

Using Quotes In A String

Jun 14, 2006

Is there a way to generate a string for a text field that has Quotes in it.

I want to generate a string for a text field that has the following text in it.

The "ShankServer" has passed the test.

I need the Quotes (") to be in the text and of course the following will not work.

Me.GeneratedCode = "The "ShankServer" has passed the test."

View 3 Replies View Related

HELP! Customer Database, Quotes, Etc.

Jan 31, 2007

A friend pointed me in the direction of this site, and I sure hope someone can help. I need to build databases that will primarily be used for creating sales quotes. I know my way around, a little bit, but I am having trouble building this database. Would anyone be interested in helping me?

View 3 Replies View Related

Paragraphs In Text Field And Using Quotes

Jun 14, 2006

I have a button that generates text according to information in different fields. The text has multiple lines and when I select the button to generate the text it puts all the lines together when I need it to do a new paragraph after each line.

Sample:
Me.GeneratedCode = "This is a test for " & Me.ServerName & "." & _
"The server " & Me.TestResults & " the test."

The above shows up in one continues line.
This is a test for shankserver. The server Passed the test.

I what it to look like this

This is a test for shankserver.
The server Passed the test.

View 1 Replies View Related

Escape Double Quotes In A String??

Jun 25, 2007

How do you guys escape the double quotes in the string..

Code:sRandomNumber = "1234"sCmdLine = "-RandomNumber="" & sRandomNumber & """

I tried this but this doesn't work...

sCmdLine = "-RandomNumber=""" & sRandomNumber & """"


I tried another method which doesn't work either...

sCmdLine = "-RandomNumber=" & chr(34) & sRandomNumber & chr(34).

What I got instead is this..

--snip--
-RandomNumber=""1234""
--snip--

Thanks...

View 5 Replies View Related

Creating New Database On Customer Quotes?

Jul 13, 2012

I am assigned to create a customer quote database for our company. Now it is in excel and already have 40,000 records and increasing average 25 records everyday. The way they want to send quotes are:

- The number of items in the quote are varied from 1 o 15.

- Each item has six different prices, depends on the order qty and want to mention in different adjusent lines.

- Each item has different delivery time depend on order qty.

- Company's sales Terms and conditions need to be printed at the end of each quote in separate page. (two full pages)

How do I create the table to accommodate all these fields? Is it possible to accommodate all items/sub items in one table under one qutoe id. I have customer table, product table etc ready and little confused to create the Quote table.

View 2 Replies View Related

Quoting Double Quotes In A Select String

Oct 24, 2004

Could someone tell me if I need to break this select statement down? I'm running into problems with the DMax statement since it requires double quotes around it's arguments. When the parser hits the first argument, it closes the string like it's supposed to, but not the way I want it to.

In essence, the query returns 4 fields: unique ID, week number, computed score (TotSum), and the computed handicap (which is half the difference between your score and the high scorer):

Quote: strSQL = "SELECT tblRoster.HEDR, tblScores.WeekNo, " & _
"[A1T1]+[A1T2]+[A1T3]+[A2T1]+[A2T2]+[A2T3]+[A3T1]+[A3T2]+[A3T3] AS TotSum, " & _
"Round(((DMax("[TotSum]", "[qryHandicap]") - [TotSum]) / 2) + 0.1) AS Handicap " & _
"FROM tblRoster LEFT JOIN tblScores ON tblRoster.HEDR = tblScores.HEDR " & _
"WHERE (((tblScores.WeekNo) = " & inpWeekNum & ") And (TotSum > 0)) " & _
"ORDER BY TotSum DESC;"


What would the proper syntax be and/or is there a better way to obtain this information. After acquired, it is being salted away in a table which is recomputed after each competition.

Thanks for the input.

-Brian.

p.s. I know storing computed fields is a big no-no, but if you do not compete in a given week, the handicap from the last time you participated is used. This table will store the participants handicap as well as the last competition they were in. It seemed easier this way.

View 3 Replies View Related

General :: Field Default Value In Double Quotes

Jul 22, 2012

On an existing DB i have set a default value for a field. The customer has now asked that they be able to change this default. I thought, hey, no big problem. They have SuperUsers, so i included a little pop up form that lists all the current valid values for that field (from a look up table). If the default value needs to change a superuser can access this and select the new default. That works fine. The trouble comes when setting the default value on a form.

I figured a simple bit of VBA in the OnOpen event - Me.cmbTypes.Value = Me.cmbTypes.DefaultValue - should work. However the value it returns from the default is ""xxxx"" and as such it is read as "". I can work around it by removing the extra " " but WHY does it do this? Would it be better to set this up as a custom property of the DB?

Using Access 2003

View 5 Replies View Related

Queries :: Invalid Syntax In Query - Enclose Text Data In Quotes

Sep 12, 2013

Error I'm getting 'The expression you entered contains invalid syntax, or you need to enclose your text data in quotes.

Code:
If Dcount(Nz([StatFlag]),[Books],[StatFlag]="W") >0 , ((Nz([StatFlag])) ="W" , (((Nz([StatFlag]))<>"R" And (Nz([StatFlag]))<>"M" And (Nz([StatFlag]))<>"H" And (Nz([StatFlag]))<>"P") AND ((Authors.Status)="A"))

View 3 Replies View Related

Access 2013 - Submitting Quotes And Invoices With No Product / Service Details

Aug 22, 2014

How do I make quotes and invoices submittable with no product and service details? We use sale book tags and have a few tags that are voided. I want to keep them in our records as voided. I've create new quotes for these tags, labelled them as void through products and services, but I can not submit the quote. I think I can not submit the quotes because there is no Total Price amount. How do I submit quotes and then invoices for my records with no Total Price amounts?

View 2 Replies View Related

Surrounding A Field With Quotes I.e. "Name"

Dec 6, 2005

Hi,

I need to make a new table from an existing table. Each field in the output table must have a leading and trailing quote. I tried to surround the quotes with quotes (" " ") Acess says it's invalid.

For example: NewOutput: " '' " & [CustTable]![FirstName] & " " ".

This does not work.

Any ideas.

Thank you,
John

View 2 Replies View Related

Removing "quotes" With A Query

Mar 31, 2005

Hello:

I am linking to a txt file from an Access DB. I am trying to write a query that will return a field that parses the leading and lagging "s that are around the name in the name field, e.g., "don smith". What I need in the revised field is simply, don smith. Because I am linking to the file, I only have read access and thus I cannot delete the "'s with vba from a form.

Thank you very much for your assistance,

View 2 Replies View Related

Forms :: Populate Combo Boxes With Values Depending On Selected Value In Previous Combo Box

Aug 5, 2013

I have several comboboxes (6) on my form.How to populate these comboboxes with values depending on selected value in previous combobox.

Example.Lets say that you select value "Audi" in combobox 1, then available values in combobox 2 should be "A4","A6","TT" etc. and if you selected "BMW" in combobox 1, then available values in combobox 2 should be "3-series", "5-series" etc...

View 1 Replies View Related

Forms :: Change Record Source Of Combo Box On Form Based On Another Combo Box

Mar 31, 2014

I have a form that currently uses a "catch all" table for listing available equipment to choose from for an equipment field. I call it tblEquipment. What I want to do is to make it so when I type a name in (1 of 35) in one field of the current record, the record source for the equipment field immediately looks at a different table that has equipment available only for that name. To do this I plan on making 35 different tables with limited data originally found in tblEquipment. I would call these tblEquipment1, tblEquipment2, etc. I do not use a sub form, nor do I want to.

So my questions are:

1) can this be done
2)If it can be done, how can I do it?

View 3 Replies View Related

Change Combo Contents Based On Previous Combo Selection

Oct 20, 2005

Hi everyone,

I have two combo boxes on the same form bound to a table. I want the contents of the next combo box to change based on the previous combo selection e.g

cboContinent cboCountry
Africa Zambia
Africa Congo
Africa South africa
Europe England
Europe Holland

If I choose Africa in cboContinent, I want to see only Zambia, South Africa and Congo under cboCountry and if I choose Europe I want to see only England and Holland

Thanks
Humphrey

View 1 Replies View Related

Forms :: Filtering A Combo Box On A Subform From A Combo Box On A Main Form

Apr 27, 2013

I have a Suppliers database which contains a form that will allow me to place orders with Suppliers.The Main form has a combo box that allows me to select the supplier. The combo box is called SupplierID with the following:

Row source: SELECT Suppliers.SupplierID, Suppliers.CompanyName FROM Suppliers ORDER BY Suppliers.CompanyName;

The subform is called Stock Subform witha combo box called ProductID with the following:

Row source: SELECT DISTINCT Products.ProductID, Products.ProductName, Suppliers.CompanyName, Products.Discontinued FROM Suppliers INNER JOIN Products ON Suppliers.SupplierID=Products.SupplierID WHERE (((Products.Discontinued)=0)) ORDER BY Products.ProductName;
Event Procedure - AfterUpdate: Private Sub ProductID_AfterUpdate()
On Error GoTo Err_ProductID_AfterUpdate
Dim strFilter As String
' Evaluate filter before it's passed to DLookup function.
strFilter = "ProductID = " & Me!ProductID

[code]..

The Link fields are done on the Purchase Order ID (PONoID).What I want to achieve is to select the supplier from the combo box (SupplierID) on the main form and then the combo box (ProductID) on the subform to filter to only show products directly supplied by the Supplier selected on the Main Form.

View 11 Replies View Related

Forms :: Fill Text Box Based On Combo Box (not Using Columns In Combo Box)

May 21, 2014

I'm looking for a way to have a text box auto fill based on the selection of a combo box on the same form. I cannot use the method i find all over the internet of using multiple columns in the combo box and basing the text box on that because the combo box already has multiple columns being used to determine its own possibilities and other combo box possibilities.

I would really just like the text box to work like this, but im still kinda inexperienced in VBA...

If combo box is "F004-001", then text box is "237"
If combo box is "F004-003", then text box is "280"

I know how to add in an "after update" thing, but i do not know how to do If/then statements.

View 1 Replies View Related

Populate Combo Box Based On Selection In Another Combo Box (Access 2010)

Jul 11, 2012

I'm have quite a difficult time getting a form in Access 2010 to perform the way I would like it to. I have multiple tables that I've created, and a query that contains the data from the various tables. I then ran the form wizard to select the data from the query that I wanted to populate in my form and I've added 2 combo boxes.

What I want to do:
1. I want users to be able to select a category in combo box #1 (example: "Bag")
2. I want users to be able to select a detail in combo box #2 based on the category they selected in combo box #1 (example: Combo box #1, "bag" would populate the following selections for combo box #2: "sandwich" and "tool")
3. I want users to then receive a list of suppliers that provide the product they have selected, either "Bag: Sandwich" or "Bag: Tool"

I have combo box #1 populating a list of categories already. However, I am not able to get combo box #2 to provide choices based on the selection chosen for combo box #1.

View 1 Replies View Related

Filtering Combo Box Based On A Value From Another Combo Box (in Multiple Items Form)

Mar 11, 2012

Let's assume we have 3 tables:

Order_Category (Order_Category_ID, Order_Type_Name) with 2 records:
1, Minor
2, Major

Order_Type (Order_Category_ID, Order_Type) with 4 records:
1, Book
1, Pencil
2, Car
2, House

Orders (Order_Category_ID, Order_Type, value) with 2 records:
1, NULL, NULL
1, NULL, NULL
2, NULL, NULL

I want to create a Multiple Items form presenting Orders table with two Combo Boxes:

1. A combo box to select Order_Category_ID.
2. A combo box to select Order_Type. When 1 (Minor) is chosen in the first combo box it should show Book and Pencil, when 2 (Major) is chosen it should show Car and House.

Examples in the Internet show how to do it on a 'single row' forms using the RowSource property. I tried to use a query like:

SELECT Order_Type
FROM Order_Type
INNER JOIN Orders ON Order_Type.Order_Category_ID = Orders.Order_Category_ID
WHERE Order_Category_ID = [comboBoxOrderCategoryID]

But it sets same values for all records in the Multiple Items form and it should return different values in each rows based on value in the first combo box (Order_Category_ID).

View 5 Replies View Related

Combo Box Performs Query, Update Combo Box With Only Result?

Aug 4, 2006

Here's the deal:

I'm an extreme newbie, I do not know access very well, nor do I know VBA, I do know PHP.

I have a for in access that has 2 user input fields, one for prodid one for shipid. I have a combo box that upon entering data into the previous 2 fields, it does a query against an MsSQL database looking for a record that has both. In any case there will only be 2 outcomes, either 1 record, or null. I would like to have that same combo box automatically use the result as it's value so that users don't have to check the box, because they won't, and so that the rest of my VBA will be able to function properly.

Can anyone assist?

Thanks.

View 2 Replies View Related







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