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

A concatenate question in reverse

I have a query that pulls the right info but I am tring to display it in a form

The data looks like this

autonumber usernumber userfirstname userlastname checkbox
0000 0001 john smith false
0001 0001 john smith false
0002 0001 john smith true
0003 0002 sally jones true
0004 0002 sally jones true
0005 0002 sally jones false

I would like it displayed like this

usernumber userfirstname userlastname checkbox autonumber
0001 john smith false 0000, 0001
0001 john smith true 0002
0002 sally brown false 0005
0002 sally brown true 0003, 0004

I have all but the autonumber set up correctly. I am a bit new to the visual basic part of Access any help will be welcomed.
May 3 '10 #1

✓ answered by TheSmileyCoder

No it would not. It would however allow you a easy way to display such items in a subform, and you could even tie events to the subform, so that when a user clicks a payroll, that payroll gets opened.

Now if you need it comma delimited, you would need to write a function for that, as far as I know.

It could go something like this.

Again I would base the form on your user table, and then add a custom function in a textbox, this ensures that the function will not be called for all your users, but only for those you are actually displaying in the form.

Expand|Select|Wrap|Line Numbers
  1. Private Function fStrPayrolls(UserNumber as long) as string
  2.   Dim rsPR as DAO.Recordset
  3.   Dim strSQL as string
  4.   strSQL="SELECT * FROM tbl_Payroll WHERE usernumber=" & UserNumber & " ORDER BY autonumber"
  5.   set rsPR=CurrentDB.OpenRecordSet(strSQL,dbopendynaset,dbReadOnly)
  6.   Dim strResult as string
  7.   do while not rsPR.EOF
  8.     strResult=strResult & "," & rsPR!Autonumber
  9.     rsPR.MoveNext
  10.   Loop
  11.   fStrPayrolls=strResult
  12.  
  13. End Function

7 2091
dsatino
393 256MB
you can't do this with a single query
May 3 '10 #2
TheSmileyCoder
2,322 Expert Mod 2GB
Try to explain what you need, because it sounds like you might not have setup your tables properly. Depending on your needs, I would likely suggest using a subform,but I need to know more about what you need this for.
May 3 '10 #3
dsatino
393 256MB
I would agree, but this isn't my question. I'm new to this today so I probably responded in the wrong place somehow. Given your expert status, I'd love it if you could look at my question regarding how to use a custom function as both a filter and a non-filter. Thanks!
May 3 '10 #4
@TheSmileyOne
Ok, I have everything but the last part of this query setup and I am trying to list the series of autonumbers 0000,0001,0002,0003 That is attached to a specific user This is for a payroll form and report to show payout to the listed autonumbers
May 3 '10 #5
TheSmileyCoder
2,322 Expert Mod 2GB
What is your table structure? Do you have a Table of users and a seperate table of payrolls? Are they related by the UserNumber?

If so, what you likely need to do, is first setup a form, tied to user table, then insert a subform (simplest approach is to drag the payroll table into the user form, while in design view, and then setup the Parent/child relation between the 2 forms).
May 3 '10 #6
@TheSmileyOne
this will not help list a single column from mydatabase to a comma delimited list in a textbox on my form
May 3 '10 #7
TheSmileyCoder
2,322 Expert Mod 2GB
No it would not. It would however allow you a easy way to display such items in a subform, and you could even tie events to the subform, so that when a user clicks a payroll, that payroll gets opened.

Now if you need it comma delimited, you would need to write a function for that, as far as I know.

It could go something like this.

Again I would base the form on your user table, and then add a custom function in a textbox, this ensures that the function will not be called for all your users, but only for those you are actually displaying in the form.

Expand|Select|Wrap|Line Numbers
  1. Private Function fStrPayrolls(UserNumber as long) as string
  2.   Dim rsPR as DAO.Recordset
  3.   Dim strSQL as string
  4.   strSQL="SELECT * FROM tbl_Payroll WHERE usernumber=" & UserNumber & " ORDER BY autonumber"
  5.   set rsPR=CurrentDB.OpenRecordSet(strSQL,dbopendynaset,dbReadOnly)
  6.   Dim strResult as string
  7.   do while not rsPR.EOF
  8.     strResult=strResult & "," & rsPR!Autonumber
  9.     rsPR.MoveNext
  10.   Loop
  11.   fStrPayrolls=strResult
  12.  
  13. End Function
May 3 '10 #8

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

Similar topics

6
by: Sheldon | last post by:
Hi, I am trying to build a large array using concatenate function in python. So as I loop over the number of arrays, of which there are 12 (4 down and 3 across), I create 3 long arrays by...
4
by: roxorsoxor2345 | last post by:
I have this custom string class that I have created. #include <cstdlib> #include <iostream> using namespace std; class Cstring { private:
14
by: metamorphiq | last post by:
Hello, I'm a Java programmer, so I'm probably asking a very simple question here, but I have trouble solving it :) I'd like to know how you concatenate multiple (4, in my case) char* in C++,...
41
by: rick | last post by:
Why can't Python have a reverse() function/method like Ruby? Python: x = 'a_string' # Reverse the string print x Ruby: x = 'a_string' # Reverse the string
2
by: exapplerep | last post by:
I've seen how to use VBA code to concatenate two fields into a third by using an expression in the "After Update" property in fields 1 & 2. field3 = field1 + field2 The above code would go...
4
by: Dan | last post by:
Hi all, I am creating a search table where the keywords field is made up of several text fields and this is causing me some problems. I can concatentate the text ok but i can't seem to concatenate...
12
by: parth | last post by:
Hi I want to achieve the following transformation of data using a stored procedure. Source col1 col2(varchar) -------------------------
13
by: sinbad | last post by:
hi, how to concatenate a "hash defined" constant value to another "hash defined" constant string. For example #define ABC 100 #define MYSTR "The value of ABC is" Now i need a string that...
10
by: Aaron Hoffman | last post by:
Hello, I'm hoping someone might be able to offer some guidance to my problem. I have one query in MS Access which consists of 2 tables joined by a SEQUENCE_ID. By joining the two tables I am...
7
beacon
by: beacon | last post by:
Hi everybody, This may be an easy one, but I'm having a lot of trouble with it. I have a continuous form and I want to validate that the user has entered something in each of the required fields...
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
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
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
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...
0
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
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.