473,509 Members | 2,918 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Concatenation produces calculation instead of concatentation

Greetings,

I'm using the procedure below to insert records into a table which contains a
field (SalesOrder) that must be in the format

8-1
8-2
8-3
8-4

etc.

I placed a MsgBox statement to see the concatenation result which seems correct
but when I look at the result in the table I get

7
6
5
4

The results of a calculation!! I tried various ways using the CStr function
with no success.
8-1= 7
8-2 = 6
8-3 = 5
8-4 = 4

Private Sub cmdInsertRecords_Click()
Dim dbs As DAO.Database
Dim intStart As Integer
Dim intEnd As Integer
Dim intMonth As Integer
Dim intCounter As Integer

intStart = Me.txtStart
intEnd = Me.txtEnd
intMonth = Me.txtMonth

Set dbs = CurrentDb

For intCounter = intStart To intEnd
dbs.Execute " INSERT INTO tblInvoices " & _
"(SalesOrder) Values " & _
"(" & intMonth & " - " & intCounter & ");"

MsgBox intMonth & "-" & intCounter

Next intCounter

dbs.Close
Set dbs = Nothing

End Sub

Any ideas would be appreciated.

Thanks

Ed Marzan
NYC
Nov 12 '05 #1
2 1807
If you want SQL to recognize a string as such, you must surround it with
quotes or single quotes.
Here's one way you could try:

dbs.Execute " INSERT INTO tblInvoices " & _
"(SalesOrder) Values " & _
"('" & intMonth & " - " & intCounter & "');"

HTH
- Turtle
"Ducojansen" <du********@aol.com> wrote in message
news:20***************************@mb-m15.aol.com...
Greetings,

I'm using the procedure below to insert records into a table which contains a field (SalesOrder) that must be in the format

8-1
8-2
8-3
8-4

etc.

I placed a MsgBox statement to see the concatenation result which seems correct but when I look at the result in the table I get

7
6
5
4

The results of a calculation!! I tried various ways using the CStr function with no success.
8-1= 7
8-2 = 6
8-3 = 5
8-4 = 4

Private Sub cmdInsertRecords_Click()
Dim dbs As DAO.Database
Dim intStart As Integer
Dim intEnd As Integer
Dim intMonth As Integer
Dim intCounter As Integer

intStart = Me.txtStart
intEnd = Me.txtEnd
intMonth = Me.txtMonth

Set dbs = CurrentDb

For intCounter = intStart To intEnd
dbs.Execute " INSERT INTO tblInvoices " & _
"(SalesOrder) Values " & _
"(" & intMonth & " - " & intCounter & ");"

MsgBox intMonth & "-" & intCounter

Next intCounter

dbs.Close
Set dbs = Nothing

End Sub

Any ideas would be appreciated.

Thanks

Ed Marzan
NYC

Nov 12 '05 #2
Hi Turtle

Thanks for the reply. Your suggestion worked perfectly.

Interesting... I also received an email with your response from
developersindex.com. Can anyone explain how that works?

In article <fn*******************@newsread2.news.atl.earthlin k.net>,
"MacDermott" <ma********@mindspring.com> writes:
Subject: Re: Concatenation produces calculation instead of concatentationFrom: "MacDermott" <ma********@mindspring.com>
Date: Sat, 20 Sep 2003 10:56:11 GMT

If you want SQL to recognize a string as such, you must surround it with
quotes or single quotes.
Here's one way you could try:

dbs.Execute " INSERT INTO tblInvoices " & _
"(SalesOrder) Values " & _
"('" & intMonth & " - " & intCounter & "');"

HTH
- Turtle

Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
14124
by: G Kannan | last post by:
Hey all! I have written a perl script to retrieve information from a HTML Form and insert the data into an Oracle database table. I am gettting the the following error message: "Use of...
7
8018
by: Paul Davis | last post by:
I'd like to overload 'comma' to define a concatenation operator for integer-like classes. I've got some first ideas, but I'd appreciate a sanity check. The concatenation operator needs to so...
37
4653
by: Kevin C | last post by:
Quick Question: StringBuilder is obviously more efficient dealing with string concatenations than the old '+=' method... however, in dealing with relatively large string concatenations (ie,...
5
7142
by: Paxtonend | last post by:
I want to concatenate the values from two columns in the datatextfield of a drop down list, so that it displays a series of job titles followed by the count of job titles in brackets, e.g. Job...
9
2037
by: Justin M. Keyes | last post by:
Hi, Please read carefully before assuming that this is the same old question about string concatenation in C#! It is well-known that the following concatenation produces multiple immutable...
33
4634
by: genc_ymeri | last post by:
Hi over there, Propably this subject is discussed over and over several times. I did google it too but I was a little bit surprised what I read on internet when it comes 'when to use what'. Most...
4
2105
by: Cristian.Codorean | last post by:
I was just reading a "Python Speed/Performance Tips" article on the Python wiki http://wiki.python.org/moin/PythonSpeed/PerformanceTips and I got to the part that talks about string concatenation...
34
2616
by: Larry Hastings | last post by:
This is such a long posting that I've broken it out into sections. Note that while developing this patch I discovered a Subtle Bug in CPython, which I have discussed in its own section below. ...
5
6223
by: The alMIGHTY N | last post by:
Hi all, Let's say I have a simple math formula: sum (x * y / 1000) / (sum z / 1000) I have to do this across 50 items, each with an x, y and z value, when the page first loads AND when a...
0
7237
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
7137
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
7416
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...
1
7073
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
7506
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5062
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
3218
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
1571
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
443
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.