473,503 Members | 10,245 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Concatenating hyphenated numbers with text

3 New Member
Using a setvalue macro, I'm trying to concatenate several fields, all of which are set as 'text', but some of which contain only numbers. (Gathering data from a form into one field, then saving this back to the table)
I have got around the problem by using CStr(), but this isn't working for one field, where I have two numbers (page numbers) seperated with a hyphen, e.g. 378-392. If I leave out the Cstr(), I get a Type Mismatch error, if I include it, I get a concatenated result but with Error 0 at the place where this field value should be.

I'm using Access 2002, and am not very experienced, as may be obvious.

Any help appreciated.
Oct 11 '07 #1
5 3052
nico5038
3,080 Recognized Expert Specialist
Hmm, strange.
When you concatenate the fields, are you using the "&" or the "+" sign ?
Can you post the code you have ?

In general when concatenating fields and having one text field, will turn the entire concatenation into a textstring concatenation....

Nic;o)
Oct 11 '07 #2
rajsa
3 New Member
Here goes:

I have a form in which the user enters the various parts of journal citations, e.g. Authors, Year etc. What I want is for one field to display the whole citation, by concatenating these fields, and then save that concatenated value to a field in my table.

In my setvalue macro I have the following:
Item: [Reference]
Expression:
Expand|Select|Wrap|Line Numbers
  1. [Authors] & " (" & CStr([Year]) & ") " & [Title] & " " & [Publication] & " " & CStr([Volume]) & ": " & CStr([Pages]) & "."
As I've said, when I delete the last section (Pages), it works fine, but as soon as I use the full code above, whether I use the final CStr() or not, I get errors. I'm assuming this is because Access sees the hyphen in the Pages field (e.g. 378-402) as a minus sign and therefore doesn't know what to do with it??

All fields are set as text, however [Year], [Volume] and [Pages] contain only numbers. I found that using CStr() worked for the first two (got rid of my type mismatch) by trial and error.

Thanks!
Oct 12 '07 #3
nico5038
3,080 Recognized Expert Specialist
Hmm, looks like the syntax is OK, but when you would use this on a report the [Pages] would give you the number of report pages, instead of the desired value from your table. Could you try to change the fieldname "Pages" in the table into "BookPages" and rebuild the string to use that field instead ?

Nic;o)
Oct 12 '07 #4
rajsa
3 New Member
Thanks - I'll change the field name, I hadn't thought of that (would have probably flummoxed me when I came to producing a report!)

I ditched the setvalue macro idea for now - pasting the same expression (without the CStr() functions) into an update query worked perfectly, and I've just added a button to the form so whenever new references are added, the query can be run.
Oct 12 '07 #5
nico5038
3,080 Recognized Expert Specialist
Glad I could help. The "reserved words" (like Pages, etc.) are indeed a nasty problem to detect. "Qualifying" fieldnames (like BookPages and DateSold) does often help.

Success with your application !

Nic;o)
Oct 12 '07 #6

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

Similar topics

14
5484
by: Larry R Harrison Jr | last post by:
I have designed databases but have never come across any complications due to the ridiculous situation of a hyphenated last name. As a database designer (very junior level) I disdain anything...
1
1759
by: pcb | last post by:
Hi All, I have a procedure that concatenates sample numbers. The format of the numbers are B-00001, B-00002, etc. For example, if I have 3 sample numbers and I want to concatenate them as...
4
2318
by: Juan | last post by:
Does any one know if there are reported bugs when concatenating strings? When debugging each variable has the correct value but when I try to concatenate them some values are missing (I can´t see...
4
1777
by: FB's .NET Dev PC | last post by:
Interesting note, the code below as is will attempt to cast what is clearly indicated as a string into a double. This is becuase the use of + as a concatenation operator. The error message...
4
2585
by: Antonio Tirado | last post by:
Hi, I'm using the OleDB namespace to open a CSV File. I can read the file sucessfully except for hyphenated values. My CSV File contains phone numbers and sometimes these come separated with...
4
1643
by: lindiwemaduna | last post by:
I want to concatenate values of two text boxes into one string but these should be separated by a space in the database table. i have tried all the following but twas not successful: Dim fullName...
7
2761
by: Mary | last post by:
I have a student who has a hyphenated first name. If I concatenate the name like this: StudentName:( & ", " & ), it works as expected. If, however, I try to get the first name first by...
1
2550
by: plumba | last post by:
Hi all. I have a form which has a table and within the rows of the table are simple text input boxes. The ONLY problems with this is that when the form is posted (in text format) if the number of...
4
2824
by: clinisbut | last post by:
I'm not sure if this is the right group, but I didn't found any other more appropiate to post my problem. I'm trying to concatenate chars using the Glib library and I'm getting strange...
0
7193
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
7067
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
7264
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,...
1
6975
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
5562
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4992
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
3148
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1495
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
371
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.