473,378 Members | 1,699 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Combining records in access 2007

I just found this site, and have found some great information. My question is in reguards to this post here: http://www.thescripts.com/forum/thread569535.html

My question is this, First can this be used if the table has 7 columns(named Field1 through Field7). Secondly if so How?

I am really new to vb, and understand some, but not much. I appreciate the help and look forward to contributing to this forum once i get more knowledge. and training.

Thanks in advance.
Dec 26 '07 #1
3 1864
I just found this site, and have found some great information. My question is in reguards to this post here: http://www.thescripts.com/forum/thread569535.html

My question is this, First can this be used if the table has 7 columns(named Field1 through Field7). Secondly if so How?

I am really new to vb, and understand some, but not much. I appreciate the help and look forward to contributing to this forum once i get more knowledge. and training.

Thanks in advance.

I figured it out, took some time, but in the end wasn't hard at all just some simple changes. I'll post my code up later to help others that want to perform this with multiple fields.
Dec 27 '07 #2
this is my module code:
Expand|Select|Wrap|Line Numbers
  1. Public Function Concat(strField1 As String, _
  2.                        strField2 As String, _
  3.                        strField3 As String, _
  4.                        strField4 As String, _
  5.                        strField5 As String, _
  6.                        strField6 As String, _
  7.                        strField7 As String) As String
  8.  
  9.     Static strLastField1 As String
  10.     Static strCombined As String
  11.  
  12.     If strField1 = strLastField1 Then
  13.         strCombined = strCombined & ", " & strField2 & ", " & strField3 & ", " & strField4 & ", " & strField5 _
  14.         & ", " & strField6 & "," & strField7
  15.     Else
  16.     'Correct
  17.         strLastField1 = strField1
  18.         strCombined = strField2 & ", " & strField3 & ", " & strField4 & ", " & strField5 & ", " & strField6 _
  19.         & ", " & strField7
  20.     End If
  21.     Concat = strCombined
  22. End Function
and my query is:

Expand|Select|Wrap|Line Numbers
  1. SELECT Table1.Field1, Max(ConCat(Field1,Field2,Field3,Field4,Field5,Field6,Field7)) AS COMBINED
  2. FROM Table1
  3. GROUP BY Table1.Field1;
The problem is once those fields are concatenated they are larger than 255 characters. So is there anyways around that? I am sure a memo field. Maybe using append table after making the table correctly using a memo field? Error I get is Data type mismatch in criteria expression? Any help?

Thanks.
Dec 27 '07 #3
puppydogbuddy
1,923 Expert 1GB
this is my module code:
Expand|Select|Wrap|Line Numbers
  1. Public Function Concat(strField1 As String, _
  2.                        strField2 As String, _
  3.                        strField3 As String, _
  4.                        strField4 As String, _
  5.                        strField5 As String, _
  6.                        strField6 As String, _
  7.                        strField7 As String) As String
  8.  
  9.     Static strLastField1 As String
  10.     Static strCombined As String
  11.  
  12.     If strField1 = strLastField1 Then
  13.         strCombined = strCombined & ", " & strField2 & ", " & strField3 & ", " & strField4 & ", " & strField5 _
  14.         & ", " & strField6 & "," & strField7
  15.     Else
  16.     'Correct
  17.         strLastField1 = strField1
  18.         strCombined = strField2 & ", " & strField3 & ", " & strField4 & ", " & strField5 & ", " & strField6 _
  19.         & ", " & strField7
  20.     End If
  21.     Concat = strCombined
  22. End Function
and my query is:

Expand|Select|Wrap|Line Numbers
  1. SELECT Table1.Field1, Max(ConCat(Field1,Field2,Field3,Field4,Field5,Field6,Field7)) AS COMBINED
  2. FROM Table1
  3. GROUP BY Table1.Field1;
The problem is once those fields are concatenated they are larger than 255 characters. So is there anyways around that? I am sure a memo field. Maybe using append table after making the table correctly using a memo field? Error I get is Data type mismatch in criteria expression? Any help?

Thanks.
Check the data types of the fields in your table. One or more may be defined as other than the text(string) data type used in your code. If you find for example, field3 is numeric, one way around is to use an Access function to convert the data type in your code....CStr(field3).
Jan 5 '08 #4

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

Similar topics

4
by: mike | last post by:
I have a database table like the following: id|name|item_id|sequence and the following instance data: 1|Apple|419841|1 2|Orange|419841|2 3|Banana|935890|1 4|Lime|959081|1
5
by: JasonP | last post by:
I am using Access 2003 on Windows XP. I am looking to analyse web traffic files using this - I appreciate there are bespoke applications which will do the same task. Each month there are roughly...
2
by: rdraider | last post by:
Using SQL 2000, how can you combine multiple records into 1? The source data is varchar(255), the destination will be text. I need help with the select statement. example tables: CREATE TABLE ...
5
by: Neil | last post by:
I'm running Access 2000 with a SQL 7 back end, using ODBC linked tables in an MDB file. The db is used by about 30 users on a LAN, and an additional 10 or so on a WAN. Recently, one of the WAN...
3
by: cjbutler | last post by:
Hi, I am using MS Access 2003 on a Windows XP platform. I am wondering what the best way is to go about combining data from 4 tables. Here is a sample from all 4 tables, with what I would like...
6
by: mservice | last post by:
Hi there, newbie to Access, I would normally use cursors in SQL Plus to do this type of thing, however I have been tasked with modifying an access 2000 application and am stuck on the VB code/query...
3
by: dfritt | last post by:
I have a table with records that I want to split up based on a start and end date. I am new MS Access and VB and would appreciate an example of some code that could be used to do this ?, even...
3
by: masonic35and7 | last post by:
I work for a school district, and I have just imported 6 Excel worksheets into Access 2007. Now I have 6 different tables. In each table all the fields are the same. I need the easiest way to...
8
by: Dr Al | last post by:
I have a table with four date fields, some of which may not be filled in based on our data entry needs. I have a criteria set as <date()-180 which is supposed to pull dates older than 180 days ago....
3
by: Ken Fine | last post by:
This is a question that someone familiar with ASP.NET and ADO.NET DataSets and DataTables should be able to answer fairly easily. The basic question is how I can efficiently match data from one...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.