A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

FORMAT A CSV



 
 
Thread Tools Display Modes
  #1  
Old July 6th, 2009, 12:22 AM posted to microsoft.public.access
Glint
external usenet poster
 
Posts: 165
Default FORMAT A CSV

Hi Guys,
I have a textbox that displays a list of available numbers in a csv format:
1,9,17,3,3,7,3 etc. The problem I have is that the numbers come from
different departments and therefore get repeated. This makes it difficult for
a user to use the box effectively.
How can I create a table out of the csv, and then make the textbox display
unique numbers, not repeating a number once it is in the list?
--
Glint
  #2  
Old July 6th, 2009, 02:08 PM posted to microsoft.public.access
Jerry Whittle
external usenet poster
 
Posts: 4,732
Default FORMAT A CSV

Is the text box in a form?

How is the text box populated now?

What do the users do with the data in this text box?

If you get the csv data into a table, you could create a query with either a
DISTINCT clause or a Totals query. That would eliminate duplicates from
showing. Then you might be able to use this query as the source for the text
box. You could even sort the numbers using the query.
--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.


"Glint" wrote:

Hi Guys,
I have a textbox that displays a list of available numbers in a csv format:
1,9,17,3,3,7,3 etc. The problem I have is that the numbers come from
different departments and therefore get repeated. This makes it difficult for
a user to use the box effectively.
How can I create a table out of the csv, and then make the textbox display
unique numbers, not repeating a number once it is in the list?
--
Glint

  #3  
Old July 6th, 2009, 04:34 PM posted to microsoft.public.access
Glint
external usenet poster
 
Posts: 165
Default FORMAT A CSV

Thanks Jerry.
The textbox is an unbound one in the form, and is populated by an iteration
through other bound textboxes in the form which displays one record. Any
textbox that has the items are then listed as csv in the unbound textbox.
A user can then know where to place other items based on the position of
existing items.
--
Glint


"Jerry Whittle" wrote:

Is the text box in a form?

How is the text box populated now?

What do the users do with the data in this text box?

If you get the csv data into a table, you could create a query with either a
DISTINCT clause or a Totals query. That would eliminate duplicates from
showing. Then you might be able to use this query as the source for the text
box. You could even sort the numbers using the query.
--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.


"Glint" wrote:

Hi Guys,
I have a textbox that displays a list of available numbers in a csv format:
1,9,17,3,3,7,3 etc. The problem I have is that the numbers come from
different departments and therefore get repeated. This makes it difficult for
a user to use the box effectively.
How can I create a table out of the csv, and then make the textbox display
unique numbers, not repeating a number once it is in the list?
--
Glint

  #4  
Old July 6th, 2009, 04:54 PM posted to microsoft.public.access
John W. Vinson
external usenet poster
 
Posts: 18,261
Default FORMAT A CSV

On Sun, 5 Jul 2009 16:22:01 -0700, Glint
wrote:

Hi Guys,
I have a textbox that displays a list of available numbers in a csv format:
1,9,17,3,3,7,3 etc. The problem I have is that the numbers come from
different departments and therefore get repeated. This makes it difficult for
a user to use the box effectively.
How can I create a table out of the csv, and then make the textbox display
unique numbers, not repeating a number once it is in the list?


You'll need some VBA code to unpack this string into individual values. You
won't want to *create* a table routinely - you should have a table permanently
in the database, and you can use code to move this data from the textbox (or
the text field in your table) into a number field in the table.

See the VBA Help for the "Split" function, it gives an example.
--

John W. Vinson [MVP]
  #5  
Old July 6th, 2009, 06:21 PM posted to microsoft.public.access
Glint
external usenet poster
 
Posts: 165
Default FORMAT A CSV

Thanks a lot, John.
The Split function sounds exactly like what I may need. However, I have
problems locating an example of it in the Access 07 that I am using now. It
does give some explanation of the function, but I cannot find an exaple of
its use. Can you please help me?
--
Glint


"John W. Vinson" wrote:

On Sun, 5 Jul 2009 16:22:01 -0700, Glint
wrote:

Hi Guys,
I have a textbox that displays a list of available numbers in a csv format:
1,9,17,3,3,7,3 etc. The problem I have is that the numbers come from
different departments and therefore get repeated. This makes it difficult for
a user to use the box effectively.
How can I create a table out of the csv, and then make the textbox display
unique numbers, not repeating a number once it is in the list?


You'll need some VBA code to unpack this string into individual values. You
won't want to *create* a table routinely - you should have a table permanently
in the database, and you can use code to move this data from the textbox (or
the text field in your table) into a number field in the table.

See the VBA Help for the "Split" function, it gives an example.
--

John W. Vinson [MVP]

  #6  
Old July 6th, 2009, 06:45 PM posted to microsoft.public.access
Douglas J. Steele[_3_]
external usenet poster
 
Posts: 3,143
Default FORMAT A CSV

Dim lngLoop As Long
Dim strData As String
Dim varValues As Variant

strData = "1,9,17,3,3,7,3"
varValues = Split(strData, ",")
For lngLoop = LBound(varValues) To UBound(varValues)
Debug.Print "Element " & lngLoop & " = " & varValues(lngLoop)
Next lngLoop

will product the following output:

Element 0 = 1
Element 1 = 9
Element 2 = 17
Element 3 = 3
Element 4 = 3
Element 5 = 7
Element 6 = 3

I'll leave it to you to figure out how to go from what's in varValues to 1,
3, 7, 9, 17. (Feel free to come back if you need help...)

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Glint" wrote in message
...
Thanks a lot, John.
The Split function sounds exactly like what I may need. However, I have
problems locating an example of it in the Access 07 that I am using now.
It
does give some explanation of the function, but I cannot find an exaple of
its use. Can you please help me?
--
Glint


"John W. Vinson" wrote:

On Sun, 5 Jul 2009 16:22:01 -0700, Glint

wrote:

Hi Guys,
I have a textbox that displays a list of available numbers in a csv
format:
1,9,17,3,3,7,3 etc. The problem I have is that the numbers come from
different departments and therefore get repeated. This makes it
difficult for
a user to use the box effectively.
How can I create a table out of the csv, and then make the textbox
display
unique numbers, not repeating a number once it is in the list?


You'll need some VBA code to unpack this string into individual values.
You
won't want to *create* a table routinely - you should have a table
permanently
in the database, and you can use code to move this data from the textbox
(or
the text field in your table) into a number field in the table.

See the VBA Help for the "Split" function, it gives an example.
--

John W. Vinson [MVP]



  #7  
Old July 6th, 2009, 08:01 PM posted to microsoft.public.access
Glint
external usenet poster
 
Posts: 165
Default FORMAT A CSV

Thanks Douglas.
I am still stuck. Should I treat varValues as a table?
--
Glint


"Douglas J. Steele" wrote:

Dim lngLoop As Long
Dim strData As String
Dim varValues As Variant

strData = "1,9,17,3,3,7,3"
varValues = Split(strData, ",")
For lngLoop = LBound(varValues) To UBound(varValues)
Debug.Print "Element " & lngLoop & " = " & varValues(lngLoop)
Next lngLoop

will product the following output:

Element 0 = 1
Element 1 = 9
Element 2 = 17
Element 3 = 3
Element 4 = 3
Element 5 = 7
Element 6 = 3

I'll leave it to you to figure out how to go from what's in varValues to 1,
3, 7, 9, 17. (Feel free to come back if you need help...)

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Glint" wrote in message
...
Thanks a lot, John.
The Split function sounds exactly like what I may need. However, I have
problems locating an example of it in the Access 07 that I am using now.
It
does give some explanation of the function, but I cannot find an exaple of
its use. Can you please help me?
--
Glint


"John W. Vinson" wrote:

On Sun, 5 Jul 2009 16:22:01 -0700, Glint

wrote:

Hi Guys,
I have a textbox that displays a list of available numbers in a csv
format:
1,9,17,3,3,7,3 etc. The problem I have is that the numbers come from
different departments and therefore get repeated. This makes it
difficult for
a user to use the box effectively.
How can I create a table out of the csv, and then make the textbox
display
unique numbers, not repeating a number once it is in the list?

You'll need some VBA code to unpack this string into individual values.
You
won't want to *create* a table routinely - you should have a table
permanently
in the database, and you can use code to move this data from the textbox
(or
the text field in your table) into a number field in the table.

See the VBA Help for the "Split" function, it gives an example.
--

John W. Vinson [MVP]




  #8  
Old July 6th, 2009, 08:28 PM posted to microsoft.public.access
Douglas J. Steele[_3_]
external usenet poster
 
Posts: 3,143
Default FORMAT A CSV

No, it's an array.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Glint" wrote in message
...
Thanks Douglas.
I am still stuck. Should I treat varValues as a table?
--
Glint


"Douglas J. Steele" wrote:

Dim lngLoop As Long
Dim strData As String
Dim varValues As Variant

strData = "1,9,17,3,3,7,3"
varValues = Split(strData, ",")
For lngLoop = LBound(varValues) To UBound(varValues)
Debug.Print "Element " & lngLoop & " = " & varValues(lngLoop)
Next lngLoop

will product the following output:

Element 0 = 1
Element 1 = 9
Element 2 = 17
Element 3 = 3
Element 4 = 3
Element 5 = 7
Element 6 = 3

I'll leave it to you to figure out how to go from what's in varValues to
1,
3, 7, 9, 17. (Feel free to come back if you need help...)

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Glint" wrote in message
...
Thanks a lot, John.
The Split function sounds exactly like what I may need. However, I
have
problems locating an example of it in the Access 07 that I am using
now.
It
does give some explanation of the function, but I cannot find an exaple
of
its use. Can you please help me?
--
Glint


"John W. Vinson" wrote:

On Sun, 5 Jul 2009 16:22:01 -0700, Glint

wrote:

Hi Guys,
I have a textbox that displays a list of available numbers in a csv
format:
1,9,17,3,3,7,3 etc. The problem I have is that the numbers come from
different departments and therefore get repeated. This makes it
difficult for
a user to use the box effectively.
How can I create a table out of the csv, and then make the textbox
display
unique numbers, not repeating a number once it is in the list?

You'll need some VBA code to unpack this string into individual
values.
You
won't want to *create* a table routinely - you should have a table
permanently
in the database, and you can use code to move this data from the
textbox
(or
the text field in your table) into a number field in the table.

See the VBA Help for the "Split" function, it gives an example.
--

John W. Vinson [MVP]






  #9  
Old July 6th, 2009, 09:03 PM posted to microsoft.public.access
Glint
external usenet poster
 
Posts: 165
Default FORMAT A CSV

I give up. Please show me how to do it.
--
Glint


"Douglas J. Steele" wrote:

No, it's an array.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Glint" wrote in message
...
Thanks Douglas.
I am still stuck. Should I treat varValues as a table?
--
Glint


"Douglas J. Steele" wrote:

Dim lngLoop As Long
Dim strData As String
Dim varValues As Variant

strData = "1,9,17,3,3,7,3"
varValues = Split(strData, ",")
For lngLoop = LBound(varValues) To UBound(varValues)
Debug.Print "Element " & lngLoop & " = " & varValues(lngLoop)
Next lngLoop

will product the following output:

Element 0 = 1
Element 1 = 9
Element 2 = 17
Element 3 = 3
Element 4 = 3
Element 5 = 7
Element 6 = 3

I'll leave it to you to figure out how to go from what's in varValues to
1,
3, 7, 9, 17. (Feel free to come back if you need help...)

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Glint" wrote in message
...
Thanks a lot, John.
The Split function sounds exactly like what I may need. However, I
have
problems locating an example of it in the Access 07 that I am using
now.
It
does give some explanation of the function, but I cannot find an exaple
of
its use. Can you please help me?
--
Glint


"John W. Vinson" wrote:

On Sun, 5 Jul 2009 16:22:01 -0700, Glint

wrote:

Hi Guys,
I have a textbox that displays a list of available numbers in a csv
format:
1,9,17,3,3,7,3 etc. The problem I have is that the numbers come from
different departments and therefore get repeated. This makes it
difficult for
a user to use the box effectively.
How can I create a table out of the csv, and then make the textbox
display
unique numbers, not repeating a number once it is in the list?

You'll need some VBA code to unpack this string into individual
values.
You
won't want to *create* a table routinely - you should have a table
permanently
in the database, and you can use code to move this data from the
textbox
(or
the text field in your table) into a number field in the table.

See the VBA Help for the "Split" function, it gives an example.
--

John W. Vinson [MVP]







  #10  
Old July 6th, 2009, 10:46 PM posted to microsoft.public.access
Douglas J. Steele[_3_]
external usenet poster
 
Posts: 3,143
Default FORMAT A CSV

Try something like:

Dim lngLoop1 As Long
Dim lngLoop2 As Long
Dim lngMinValue As Long
Dim lngPlaceHolder As Long
Dim lngPrevValue As Long
Dim strData As String
Dim varValues As Variant

strData = "1,9,17,3,3,7,3"

' Split the comma-separated list into an array

varValues = Split(strData, ",")

' Sort the array into ascending order

For lngLoop1 = LBound(varValues) To UBound(varValues) - 1
lngMinValue = CLng(varValues(lngLoop1))
lngPlaceHolder = lngLoop1
For lngLoop2 = (lngLoop1 + 1) To UBound(varValues)
If CLng(varValues(lngLoop2)) lngMinValue Then
lngMinValue = CLng(varValues(lngLoop2))
lngPlaceHolder = lngLoop2
End If
Next lngLoop2
varValues(lngPlaceHolder) = varValues(lngLoop1)
varValues(lngLoop1) = lngMinValue
Next lngLoop1

' Loop through the sorted array, throwing away duplicates

lngPrevValue = CLng(varValues(0))
strData = varValues(0) & ", "
For lngLoop1 = 1 To UBound(varValues)
If CLng(varValues(lngLoop1)) lngPrevValue Then
lngPrevValue = CLng(varValues(lngLoop1))
strData = strData & varValues(lngLoop1) & ", "
End If
Next lngLoop1

' Delete the extra comma-space from the end of the string

strData = Left(strData, Len(strData) - 2)

strData will now contain unique values.


--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"Glint" wrote in message
news
I give up. Please show me how to do it.
--
Glint


"Douglas J. Steele" wrote:

No, it's an array.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Glint" wrote in message
...
Thanks Douglas.
I am still stuck. Should I treat varValues as a table?
--
Glint


"Douglas J. Steele" wrote:

Dim lngLoop As Long
Dim strData As String
Dim varValues As Variant

strData = "1,9,17,3,3,7,3"
varValues = Split(strData, ",")
For lngLoop = LBound(varValues) To UBound(varValues)
Debug.Print "Element " & lngLoop & " = " & varValues(lngLoop)
Next lngLoop

will product the following output:

Element 0 = 1
Element 1 = 9
Element 2 = 17
Element 3 = 3
Element 4 = 3
Element 5 = 7
Element 6 = 3

I'll leave it to you to figure out how to go from what's in varValues
to
1,
3, 7, 9, 17. (Feel free to come back if you need help...)

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Glint" wrote in message
...
Thanks a lot, John.
The Split function sounds exactly like what I may need. However, I
have
problems locating an example of it in the Access 07 that I am using
now.
It
does give some explanation of the function, but I cannot find an
exaple
of
its use. Can you please help me?
--
Glint


"John W. Vinson" wrote:

On Sun, 5 Jul 2009 16:22:01 -0700, Glint

wrote:

Hi Guys,
I have a textbox that displays a list of available numbers in a
csv
format:
1,9,17,3,3,7,3 etc. The problem I have is that the numbers come
from
different departments and therefore get repeated. This makes it
difficult for
a user to use the box effectively.
How can I create a table out of the csv, and then make the textbox
display
unique numbers, not repeating a number once it is in the list?

You'll need some VBA code to unpack this string into individual
values.
You
won't want to *create* a table routinely - you should have a table
permanently
in the database, and you can use code to move this data from the
textbox
(or
the text field in your table) into a number field in the table.

See the VBA Help for the "Split" function, it gives an example.
--

John W. Vinson [MVP]









 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 06:16 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.