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

concatenation & iff based on number of fields with entered data

theaybaras
Hi,
I'm still getting a feel for some things in Access. What I have is a database of scientific articles. I have an unbound memo field in which I want to have the APA style citation concatenated from other fields. I have 12 fields for author names. lets say author1, author2, author3, ... author11, author12. I need a different text in the citation if 7 or more authors are entered into the above fields. If 1-6 authors are listed citation will look like

Last1, F1. M1. (2007).
Last1, F1. M1., Last2, F2. M2. (2007).

if 7 or more authors are filled in, I need it to return

Last1, F1. M1., Last2, F2. M2., Last3, F3. M3., Last4, F4. M4., Last5, F5. M5., Last6, F6. M6., et al. (2007).

so authors 7-12 aren't returned in the calculation but are returned as "et al."
but I don't want "et al." unless there are more than 6 authors filled in for the record.

I'm just not sure how to tell the field to calculate the citation one way if it is concatenating 6 or fewer authors and another if it is concatenating 7 or more. Also I'm not sure how to account for a blank entry for the authors.

I've given it a pretty good shot and I have no problem getting it to concatenate all 12 fields (with only the ones that are not null) using either formula (with or without the "et al." before the year. But I'm not sure how to count the number of non-null values across the 12 fields in a single record.

Anyone have any ideas? I'd really appreciate any guidance you can give me.

Thanks so much, let me know if you need more information or this wasn't clear.

:)

~me
May 8 '07 #1
5 1542
MMcCarthy
14,534 Expert Mod 8TB
Hi,
I'm still getting a feel for some things in Access. What I have is a database of scientific articles. I have an unbound memo field in which I want to have the APA style citation concatenated from other fields. I have 12 fields for author names. lets say author1, author2, author3, ... author11, author12. I need a different text in the citation if 7 or more authors are entered into the above fields. If 1-6 authors are listed citation will look like

Last1, F1. M1. (2007).
Last1, F1. M1., Last2, F2. M2. (2007).

if 7 or more authors are filled in, I need it to return

Last1, F1. M1., Last2, F2. M2., Last3, F3. M3., Last4, F4. M4., Last5, F5. M5., Last6, F6. M6., et al. (2007).

so authors 7-12 aren't returned in the calculation but are returned as "et al."
but I don't want "et al." unless there are more than 6 authors filled in for the record.

I'm just not sure how to tell the field to calculate the citation one way if it is concatenating 6 or fewer authors and another if it is concatenating 7 or more. Also I'm not sure how to account for a blank entry for the authors.

I've given it a pretty good shot and I have no problem getting it to concatenate all 12 fields (with only the ones that are not null) using either formula (with or without the "et al." before the year. But I'm not sure how to count the number of non-null values across the 12 fields in a single record.

Anyone have any ideas? I'd really appreciate any guidance you can give me.

Thanks so much, let me know if you need more information or this wasn't clear.

:)

~me
Post what you are currently using to concat the 12 values. It will make it easier to work out a way to do this.
May 8 '07 #2
ADezii
8,834 Expert 8TB
Hi,
I'm still getting a feel for some things in Access. What I have is a database of scientific articles. I have an unbound memo field in which I want to have the APA style citation concatenated from other fields. I have 12 fields for author names. lets say author1, author2, author3, ... author11, author12. I need a different text in the citation if 7 or more authors are entered into the above fields. If 1-6 authors are listed citation will look like

Last1, F1. M1. (2007).
Last1, F1. M1., Last2, F2. M2. (2007).

if 7 or more authors are filled in, I need it to return

Last1, F1. M1., Last2, F2. M2., Last3, F3. M3., Last4, F4. M4., Last5, F5. M5., Last6, F6. M6., et al. (2007).

so authors 7-12 aren't returned in the calculation but are returned as "et al."
but I don't want "et al." unless there are more than 6 authors filled in for the record.

I'm just not sure how to tell the field to calculate the citation one way if it is concatenating 6 or fewer authors and another if it is concatenating 7 or more. Also I'm not sure how to account for a blank entry for the authors.

I've given it a pretty good shot and I have no problem getting it to concatenate all 12 fields (with only the ones that are not null) using either formula (with or without the "et al." before the year. But I'm not sure how to count the number of non-null values across the 12 fields in a single record.

Anyone have any ideas? I'd really appreciate any guidance you can give me.

Thanks so much, let me know if you need more information or this wasn't clear.

:)

~me
I'm a little confused as to exactly what you want, but hopefully this should point you in the right direction.
  1. Drop Author Fields 1 thru 7 (Author1...Author7) onto the Query Grid.
  2. Create a Calculated Field which calls a Function and pass the Author1 thru Author7 Fields as Arguments.
    Expand|Select|Wrap|Line Numbers
    1. Citations: fConcatenateAuthors([Author1],[Author2],[Author3],[Author4],[Author5],[Author6],[Author7])
  3. The Function should return an approximation of what you are looking for.
    Expand|Select|Wrap|Line Numbers
    1. Public Function fConcatenateAuthors(A1, A2, A3, A4, A5, A6, A7)
    2. If Not IsNull(A7) Then
    3.   fConcatenateAuthors = Nz(A1) & Nz(A2) & Nz(A3) & Nz(A4) _
    4.                         & Nz(A5) & Nz(A6) & " et al. (" & Year(Now()) & ")."
    5. Else
    6.   fConcatenateAuthors = Nz(A1) & Nz(A2) & Nz(A3) & Nz(A4) _
    7.                         & Nz(A5) & Nz(A6) & " (" & Year(Now()) & ")."
    8. End If
    9. End Function
May 8 '07 #3
missinglinq
3,532 Expert 2GB
You could enter author in the tag property of each textbox that holds an author's name, then use code like this to tally the number of authors entered:
Expand|Select|Wrap|Line Numbers
  1. Dim ctrl As Control
  2. Dim AuthorCount as Int
  3.  
  4. AuthorCount = 0
  5.  
  6. For Each ctrl In Me.Controls
  7.   If TypeOf ctrl Is TextBox Then
  8.      If ctrl.Tag = "author" Then
  9.          AuthorCount = AuthorCount + 1
  10.      End If
  11.   End If
  12. Next
  13.  
  14. If AuthorCount > 6 Then
  15.    Me.MemoField =  ConcatenatedString & "et al"
  16. End If
  17.  
May 8 '07 #4
Post what you are currently using to concat the 12 values. It will make it easier to work out a way to do this.
Thanks! Your reply was REALLY fast! True to my usual form, after posting in a forum I have at least come up with *A* way to do what I need to do. This may be a very inefficient way to do it. I realized that it really doesnt' matter if I have 12 authors listed. There will never be a null value in authors 1-6 and a non-null value in 7, authors are listed in incremental order. So I no longer needed to code for all 12. I figured out how to use the iif function. and now I have a LOT of them...
Once taking care of the authors then I append the Year from the a_year field, the title of the article from the a_title field, then the name of the journal from the a_journal field, then the volume and issue (if one is listed) from the a_volume and a_issue fields, and then the page range from a_pages. to take care of null values, I have put each of these in an iif statement. The record cannot be saved with a null value in the first author field.

My code:
Expand|Select|Wrap|Line Numbers
  1.  
  2. =[a_author1] & (IIf([a_author2] Is Null,'',', ' & [a_author2])) & (IIf([a_author3] Is Null,'',', ' & [a_author3])) & (IIf([a_author4] Is Null,'',', ' & [a_author4])) & (IIf([a_author5] Is Null,'',', ' & [a_author5])) & (IIf([a_author6] Is Null,'',', ' & [a_author6])) & (IIf([a_author7] Is Null,'',', ' & 'et al.')) & (IIf([a_year] Is Null,'',' (' & [a_year] & '). ')) & (IIf([a_title] Is Null,'',[a_title] & '. ')) & (IIf([a_journal] Is Null,'',[a_journal] & ', ')) & (IIf([a_volume] Is Null,'',[a_volume])) & (IIf([a_issue] Is Null,',','(' & [a_issue] & ')')) & (IIf([a_pages] Is Null,'.',', ' & [a_pages] & '.')) 
from the data entered into my first record, this returns...
Averill, L. A., Creamer, M. C., Rothbaum, A. B., Gentry, C. R., Astin, M. H., Jones, A., et al. (2007). How to concatenate the author fields in the way described in my previous post without really trying. Journal of Traumatic Stress, 25(4), 325-331.
or when no more than 6 authors are entered it returns...
Averill, L. A., Creamer, M. C., Rothbaum, A. B., Gentry, C. R., Astin, M. H. (2007). How to concatenate the author fields in the way described in my previous post without really trying. Journal of Traumatic Stress, 25(4), 325-331.

Is there a more efficient way to do this? (i.e. without so many iif() statements?)are there any errors that may come up that I'm not aware of. I'm not still not very up on my SQL, or even all(most) of the functions in access.

Also, the field a_journal provides an ITALIC title of journal, but a roman format for title of journal in my memo field. I'm still learning a lot of things, and am not sure if rich text is available in a memo field. Is there a way I can bring the data from a_journal into my concatenated memo field while retaining the italic format for just that piece?
May 8 '07 #5
ADezii
8,834 Expert 8TB
Thanks! Your reply was REALLY fast! True to my usual form, after posting in a forum I have at least come up with *A* way to do what I need to do. This may be a very inefficient way to do it. I realized that it really doesnt' matter if I have 12 authors listed. There will never be a null value in authors 1-6 and a non-null value in 7, authors are listed in incremental order. So I no longer needed to code for all 12. I figured out how to use the iif function. and now I have a LOT of them...
Once taking care of the authors then I append the Year from the a_year field, the title of the article from the a_title field, then the name of the journal from the a_journal field, then the volume and issue (if one is listed) from the a_volume and a_issue fields, and then the page range from a_pages. to take care of null values, I have put each of these in an iif statement. The record cannot be saved with a null value in the first author field.

My code:
Expand|Select|Wrap|Line Numbers
  1.  
  2. =[a_author1] & (IIf([a_author2] Is Null,'',', ' & [a_author2])) & (IIf([a_author3] Is Null,'',', ' & [a_author3])) & (IIf([a_author4] Is Null,'',', ' & [a_author4])) & (IIf([a_author5] Is Null,'',', ' & [a_author5])) & (IIf([a_author6] Is Null,'',', ' & [a_author6])) & (IIf([a_author7] Is Null,'',', ' & 'et al.')) & (IIf([a_year] Is Null,'',' (' & [a_year] & '). ')) & (IIf([a_title] Is Null,'',[a_title] & '. ')) & (IIf([a_journal] Is Null,'',[a_journal] & ', ')) & (IIf([a_volume] Is Null,'',[a_volume])) & (IIf([a_issue] Is Null,',','(' & [a_issue] & ')')) & (IIf([a_pages] Is Null,'.',', ' & [a_pages] & '.')) 
from the data entered into my first record, this returns...
Averill, L. A., Creamer, M. C., Rothbaum, A. B., Gentry, C. R., Astin, M. H., Jones, A., et al. (2007). How to concatenate the author fields in the way described in my previous post without really trying. Journal of Traumatic Stress, 25(4), 325-331.
or when no more than 6 authors are entered it returns...
Averill, L. A., Creamer, M. C., Rothbaum, A. B., Gentry, C. R., Astin, M. H. (2007). How to concatenate the author fields in the way described in my previous post without really trying. Journal of Traumatic Stress, 25(4), 325-331.

Is there a more efficient way to do this? (i.e. without so many iif() statements?)are there any errors that may come up that I'm not aware of. I'm not still not very up on my SQL, or even all(most) of the functions in access.

Also, the field a_journal provides an ITALIC title of journal, but a roman format for title of journal in my memo field. I'm still learning a lot of things, and am not sure if rich text is available in a memo field. Is there a way I can bring the data from a_journal into my concatenated memo field while retaining the italic format for just that piece?
You did mention the key point, any Authors entered into Fields 8 thru 12 are irrelevant, it only if Author Field #7 has an entry in it that is important. Beware of the IIF() Function! If any part of an expression containing this Function evaluates to NULL, the 'entire' expression will evaluate to NULL. This is a major drawback of using IIf() - NULLs will propagate through the entire expression.
May 8 '07 #6

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

Similar topics

5
by: EviL KerneL | last post by:
Hi - I am trying to figure out a way to enforce the validation included for this form based on whether the user chooses "email" or "phone" as the contact choice. Right now it is set to enforce...
1
by: Megan | last post by:
quick summary: i'm having problems trying to group fields in a report in order to calculate percentages. to calculate percentages, i'm comparing the results from my grouped fields to the totals....
9
by: Ray | last post by:
I need to convert the normal calendar to show the week no., the period no. and the financial year. The financial year format is as follows:- Date start: 2 May, 2005 7 days a week, 4 weeks a...
1
by: John_H | last post by:
Re: ASP.NET 2.0 I would like suggestions or code examples on how to collect a variable length list of input data (item# & item quantity specifically). I thought that I could accomplish this...
7
by: Dan | last post by:
(Using Classic ASP & MS Access) I have a page that has 120 fields on it (mostly checkboxes). I cannot split this into smaller pages. So what i want to do is write a class that handles this. in...
9
by: surf_doggie | last post by:
Im not sure if this is the group to post in, if anyone knows a more appropriate one please let me know. Please consider the following example of a feature most all browsers have that I would...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
16
by: ARC | last post by:
Hello all, So I'm knee deep in this import utility program, and am coming up with all sorts of "gotcha's!". 1st off. On a "Find Duplicates Query", does anyone have a good solution for...
17
beacon
by: beacon | last post by:
Hi everybody, I'm working with data to determine if records were completed in a given timeframe. I'm trying to figure out how I can assess records with the same ID, but have different data in...
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: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.