473,394 Members | 1,843 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,394 software developers and data experts.

vba function within Access query

fair Warning - Admittedly I'm far from an access expert, but I'm not a
beginner either.

I want to split a value into multiple parts as delimited by a character
- all as part of a query. For example, one specific column in a table
contains values like "eggs/ham/potato" and "toast/fruit" and as I run a
select query against this table, I want to split the above values into
"eggs", "ham", "potato" (3 values)and "toast","fruit" (2 values)

My research has led me to the VBA function Split() but I've been
unsuccessful in incorporating the function into a query.

Thank you for your time.

*** Sent via Developersdex http://www.developersdex.com ***
Jun 6 '06 #1
2 7664
If this is Access 2002 or 2003, you should be able to parse the first
element from field [d] with:
Split([d],"/")(0)

Access 2000 might have problems doing that.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"patrick beyries" <pa*************@keynote.com> wrote in message
news:V1****************@news.uswest.net...
fair Warning - Admittedly I'm far from an access expert, but I'm not a
beginner either.

I want to split a value into multiple parts as delimited by a character
- all as part of a query. For example, one specific column in a table
contains values like "eggs/ham/potato" and "toast/fruit" and as I run a
select query against this table, I want to split the above values into
"eggs", "ham", "potato" (3 values)and "toast","fruit" (2 values)

My research has led me to the VBA function Split() but I've been
unsuccessful in incorporating the function into a query.

Jun 6 '06 #2
On Tue, 06 Jun 2006 06:13:09 GMT, patrick beyries wrote:
fair Warning - Admittedly I'm far from an access expert, but I'm not a
beginner either.

I want to split a value into multiple parts as delimited by a character
- all as part of a query. For example, one specific column in a table
contains values like "eggs/ham/potato" and "toast/fruit" and as I run a
select query against this table, I want to split the above values into
"eggs", "ham", "potato" (3 values)and "toast","fruit" (2 values)

My research has led me to the VBA function Split() but I've been
unsuccessful in incorporating the function into a query.

Thank you for your time.

*** Sent via Developersdex http://www.developersdex.com ***


If you have Access 2000 or newer:
Copy and Paste the following into a Module:

Public Function ParseText(TextIn As String, X) As Variant
On Error Resume Next
Dim var As Variant
var = Split(TextIn, "/", -1)
ParseText = var(X)

End Function
===========

Then add 3 new columns in the query grid:

FirstCol:ParseText([FieldNamel],0)
SecondCol:ParseText([FieldNamel],1)
ThirdCol:ParseText([FieldNamel],2)

Change FieldName to what ever the actual field names is.

--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
Jun 6 '06 #3

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

Similar topics

7
by: aa | last post by:
I have beem recommended to use the Nz() function in the ORDER BY part of an Access2000 stored query. The query runs correcly from within Access2000 Yet when ran from ASP, it causes an error: ...
2
by: Stephen Bowyer | last post by:
I have an Access 97 database, which we use with a VB5 front end. If I create a new query in the database, the string functions left, mid etc do not work. For example the query: CalcField:...
10
by: Phil Latio | last post by:
Probably not the best way to do this, but I'd appreciate it if someone could tell me why the following DOESN'T work; I have a function (code below) which returns a string based upon a supplied...
2
by: Wade | last post by:
I am pretty new to Access, especially writing code, but I found code on the web to do just what I want and it is posted below. It returns a field value from a previous record. I found the code at:...
2
by: k-man | last post by:
Hi: I have an MS Access query for a table called MyTable. One of my fields in the query is a custom field that looks like "MyField: = MyFunction(ID)" where ID is a field in MyTable. I have...
4
by: wrldruler | last post by:
Hello, First, I know it's against "Access Law" to save calculations in a table, but....I want/need to. I currently have sub-totals being calculated inside a form, using DMax, DCount, and...
3
by: Libber39 | last post by:
Hi everyone, Have a query on how to calculate the amount of weeks and days contained in a number in an access query. ie: the difference in days between 2 dates amounts to 17 days. I want to now...
2
by: rmmahara | last post by:
Hi Folks, I've been reading these forums for a while and now I'm in desperate need of help, so I thought I'd post! Background: I'm creating a Service Dashboard to track my team's adherence...
1
by: giovannino | last post by:
Dear all, I did a query which update a sequence number (column NR_SEQUENZA) in a table using a nice code (from Trevor !). 1) Given that I'm not a programmer I can't understand why...
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:
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
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
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,...
0
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...

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.