Access Output - Flexible Columns

%3CLINGO-SUB%20id%3D%22lingo-sub-1887130%22%20slang%3D%22en-US%22%3EAccess%20Output%20-%20Flexible%20Columns%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1887130%22%20slang%3D%22en-US%22%3E%3CP%3EMorning%20all%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ENeed%20assistance%20with%20an%20access%20report%20and%20the%20output%20format.%26nbsp%3B%20Currently%2C%20i%20pull%20a%20report%20of%20payments%20received%20for%20a%20given%20invoice.%26nbsp%3B%20I%20can%20pull%20either%20a%20total%20payment%20received%20(if%20i%20exclude%20the%20individual%20CPT's%2Fline%20items)%20or%20i%20can%20pull%20a%20line%20item%20payment%20report.%26nbsp%3B%20However%2C%20i%20want%20the%20line%20item%20report%20option%20to%20export%20in%20a%20multiple%20column%20view%20as%20in%20the%20second%20format%20below.%26nbsp%3B%20The%20hard%20part%20is%20getting%20each%20new%20line%2FCPT%20within%20the%20invoice%20to%20move%20to%20a%20new%20column%2C%20and%20have%20the%20number%20of%20columns%20be%20flexible%20to%20adapt%20to%20the%20number%20of%20lines%2FCPT's%20on%20the%20largest%20invoice%26nbsp%3B%20in%20the%20report.%26nbsp%3B%20Currently%20the%20only%20way%20access%20will%20generate%20is%20in%20the%20first%20format%2C%20which%20i%20understand%20is%20based%20on%20how%20the%20data%20is%20stored%20in%20a%20line%20by%20line%20database%20setup.%26nbsp%3B%20Does%20anyone%20have%20experience%20with%20how%20to%20make%20this%20happen%3F%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CTABLE%20width%3D%22626%22%3E%3CTBODY%3E%3CTR%3E%3CTD%20width%3D%22297%22%3ECurrent%20Output%20-%20set%20number%20of%20columns%3C%2FTD%3E%3CTD%20width%3D%2263%22%3E%26nbsp%3B%3C%2FTD%3E%3CTD%20width%3D%2270%22%3E%26nbsp%3B%3C%2FTD%3E%3CTD%20width%3D%2263%22%3E%26nbsp%3B%3C%2FTD%3E%3CTD%20width%3D%2270%22%3E%26nbsp%3B%3C%2FTD%3E%3CTD%20width%3D%2263%22%3E%26nbsp%3B%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%3EORIG_PAYOR_NAME%3C%2FTD%3E%3CTD%3EINVOICE_NUM%3C%2FTD%3E%3CTD%3ECPT_CODE%3C%2FTD%3E%3CTD%3EAMOUNT%3C%2FTD%3E%3CTD%3E%26nbsp%3B%3C%2FTD%3E%3CTD%3E%26nbsp%3B%3C%2FTD%3E%3CTD%3E%26nbsp%3B%3C%2FTD%3E%3CTD%3E%26nbsp%3B%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%20width%3D%22130%22%3EBLUE%20CROSS%3C%2FTD%3E%3CTD%20width%3D%2297%22%3E3143609220%3C%2FTD%3E%3CTD%20width%3D%2270%22%3E21086%3C%2FTD%3E%3CTD%20width%3D%2263%22%3E-1774.92%3C%2FTD%3E%3CTD%3E%26nbsp%3B%3C%2FTD%3E%3CTD%3E%26nbsp%3B%3C%2FTD%3E%3CTD%3E%26nbsp%3B%3C%2FTD%3E%3CTD%3E%26nbsp%3B%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%20width%3D%22130%22%3EBLUE%20CROSS%3C%2FTD%3E%3CTD%20width%3D%2297%22%3E3143609220%3C%2FTD%3E%3CTD%20width%3D%2270%22%3E99202%3C%2FTD%3E%3CTD%20width%3D%2263%22%3E-126.43%3C%2FTD%3E%3CTD%3E%26nbsp%3B%3C%2FTD%3E%3CTD%3E%26nbsp%3B%3C%2FTD%3E%3CTD%3E%26nbsp%3B%3C%2FTD%3E%3CTD%3E%26nbsp%3B%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%3EAetna%3C%2FTD%3E%3CTD%20width%3D%2297%22%3E3143609230%3C%2FTD%3E%3CTD%3E31000%3C%2FTD%3E%3CTD%3E-1500%3C%2FTD%3E%3CTD%3E%26nbsp%3B%3C%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G_PAYOR_NAME%3C%2FTD%3E%3CTD%3EINVOICE_NUM%3C%2FTD%3E%3CTD%3ECPT_CODE%3C%2FTD%3E%3CTD%3EAMOUNT%3C%2FTD%3E%3CTD%3ECPT_CODE%3C%2FTD%3E%3CTD%3EAMOUNT%3C%2FTD%3E%3CTD%3ECPT_CODE%3C%2FTD%3E%3CTD%3EAMOUNT%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%20width%3D%22130%22%3EBLUE%20CROSS%3C%2FTD%3E%3CTD%20width%3D%2297%22%3E3143609220%3C%2FTD%3E%3CTD%20width%3D%2270%22%3E21086%3C%2FTD%3E%3CTD%20width%3D%2263%22%3E-1774.92%3C%2FTD%3E%3CTD%20width%3D%2270%22%3E99202%3C%2FTD%3E%3CTD%20width%3D%2263%22%3E-126.43%3C%2FTD%3E%3CTD%3E%26nbsp%3B%3C%2FTD%3E%3CTD%3E%26nbsp%3B%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%3EAetna%3C%2FTD%3E%3CTD%20width%3D%2297%22%3E3143609230%3C%2FTD%3E%3CTD%3E31000%3C%2FTD%3E%3CTD%3E-1500%3C%2FTD%3E%3CTD%3E41000%3C%2FTD%3E%3CTD%3E-125%3C%2FTD%3E%3CTD%3E51000%3C%2FTD%3E%3CTD%3E-500%3C%2FTD%3E%3C%2FTR%3E%3C%2FTBODY%3E%3C%2FTABLE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%3C%2FP%3E%3CP%3EJoe%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1887130%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAccess%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1887229%22%20slang%3D%22en-US%22%3ERe%3A%20Access%20Output%20-%20Flexible%20Columns%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1887229%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F248194%22%20target%3D%22_blank%22%3E%40JoeCavasin%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHow%20badly%20do%20you%20need%2Fwant%20this%20outcome%3F%20Enough%20to%20write%20a%20significant%20amount%20of%20VBA%3F%3C%2FP%3E%3CP%3EYou'll%20have%20to%20implement%20code%20that%20converts%20each%20payor's%20invoice%20into%20an%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Foffice%2Fvba%2FLanguage%2FConcepts%2FGetting-Started%2Fusing-arrays%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Earray()%26nbsp%3B%3C%2FA%3E%3C%2FP%3E%3CP%3EThen%20you'll%20need%20to%20figure%20out%20which%20payor%20has%20the%20largest%20number%20of%20CPT%20codes%20within%20any%20given%20invoice%20by%20counting%20the%20items%20in%20the%20array.%20Then%20you%20can%20probably%20generate%20a%20temporary%20table%20with%20that%20many%20columns.%20And%20finally%2C%20you%20can%20read%20items%20back%20out%20of%20the%20array%20into%20rows%20in%20that%20temp%20table%2C%20which%20you%20can%20then%20use%20as%20the%20report's%20recordource.%20In%20the%20report%2C%20you'll%20also%20have%20to%20write%20VBA%20to%20figure%20out%20how%20many%20columns%20will%20be%20needed%20and%20re-design%20the%20report%20accordingly.%3CBR%20%2F%3E%3CBR%20%2F%3EAll%20in%20all%2C%20quite%20a%20lot%20of%20manipulation%20and%20coding%2C%20but%20certainly%20doable.%20Is%20it%20sufficiently%20important%20to%20warrant%20that%20effort%3F%20Only%20you%20can%20decide%20that.%26nbsp%3B%3CBR%20%2F%3E%3CBR%20%2F%3ENonetheless%2C%20I%20might%20try%20my%20hand%20at%20it%20as%20an%20exercise%2C%20just%20to%20see%20what%20additional%20hurdles%20I%20haven't%20thought%20about%20yet.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1887252%22%20slang%3D%22en-US%22%3ERe%3A%20Access%20Output%20-%20Flexible%20Columns%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1887252%22%20slang%3D%22en-US%22%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F46682%22%20target%3D%22_blank%22%3E%40George%20Hepworth%3C%2FA%3E%3CBR%20%2F%3E%3CBR%20%2F%3EHonestly%20-%20considering%20i%20have%20to%20evaluate%20several%20thousand%20invoices%20at%20a%20single%20time%20it%20would%20be%20helpful%20to%20make%20it%20work.%20Typically%2C%20invoices%20don't%20go%20much%20above%205%20lines%2FCPT's%2C%20worst%20i'm%20likely%20to%20deal%20with%20would%20be%2010%20lines%2FCPT's.%3CBR%20%2F%3E%3CBR%20%2F%3EThat%20said%20-%20i%20have%20absolutely%20no%20VBA%20experience%20whatsoever.%20If%20doing%20it%20as%20an%20exercise%20with%20a%205%20or%20ten%20CPT%2Fline%20limit%20is%20a%20good%20starting%20point%2C%20i'd%20love%20to%20see%20the%20outcome.%20I%20have%20to%20escalate%20to%20payors%20monthly%20on%20behalf%20of%20our%20patients%20and%20this%20sort%20of%20single%20source%20report%20would%20make%20that%20work%20unimaginably%20simpler%20and%20more%20reliable.%3C%2FLINGO-BODY%3E
Highlighted
Contributor

Morning all,

 

Need assistance with an access report and the output format.  Currently, i pull a report of payments received for a given invoice.  I can pull either a total payment received (if i exclude the individual CPT's/line items) or i can pull a line item payment report.  However, i want the line item report option to export in a multiple column view as in the second format below.  The hard part is getting each new line/CPT within the invoice to move to a new column, and have the number of columns be flexible to adapt to the number of lines/CPT's on the largest invoice  in the report.  Currently the only way access will generate is in the first format, which i understand is based on how the data is stored in a line by line database setup.  Does anyone have experience with how to make this happen? 

 

Current Output - set number of columns     
ORIG_PAYOR_NAMEINVOICE_NUMCPT_CODEAMOUNT    
BLUE CROSS314360922021086-1774.92    
BLUE CROSS314360922099202-126.43    
Aetna314360923031000-1500    
Aetna314360923041000-125    
Aetna314360923051000-500    
        
Desired Output - flexible number of columns     
ORIG_PAYOR_NAMEINVOICE_NUMCPT_CODEAMOUNTCPT_CODEAMOUNTCPT_CODEAMOUNT
BLUE CROSS314360922021086-1774.9299202-126.43  
Aetna314360923031000-150041000-12551000-500

 

 

Thanks

Joe

5 Replies
Highlighted

@JoeCavasin 

How badly do you need/want this outcome? Enough to write a significant amount of VBA?

You'll have to implement code that converts each payor's invoice into an array() 

Then you'll need to figure out which payor has the largest number of CPT codes within any given invoice by counting the items in the array. Then you can probably generate a temporary table with that many columns. And finally, you can read items back out of the array into rows in that temp table, which you can then use as the report's recordource. In the report, you'll also have to write VBA to figure out how many columns will be needed and re-design the report accordingly.

All in all, quite a lot of manipulation and coding, but certainly doable. Is it sufficiently important to warrant that effort? Only you can decide that. 

Nonetheless, I might try my hand at it as an exercise, just to see what additional hurdles I haven't thought about yet.

Highlighted
@George Hepworth

Honestly - considering i have to evaluate several thousand invoices at a single time it would be helpful to make it work. Typically, invoices don't go much above 5 lines/CPT's, worst i'm likely to deal with would be 10 lines/CPT's.

That said - i have absolutely no VBA experience whatsoever. If doing it as an exercise with a 5 or ten CPT/line limit is a good starting point, i'd love to see the outcome. I have to escalate to payors monthly on behalf of our patients and this sort of single source report would make that work unimaginably simpler and more reliable.
Highlighted

@JoeCavasin 

It sounds worthwhile then. Actually, while I was piddling around, another approach occurred to me that might be less work. If you need up to ten CPT codes, it might get crowded on a portrait view and even landscape could be close. Anyway, I'll see what I can come up with, based on your initial sample data, which I assume does reflect the underlying source table accurately. Gimme a couple of hours but do check back as others may have ready solutions at hand.

Highlighted

@George Hepworth 

 

Thanks George.  The initial sample data in the screenshot does represent the typical layout in the database.  It is Invoice / CPT / Amount, and repeats until the number of CPT's on the Invoice are exhausted.  If an invoice has 3 or 5 or 27 CPT's, it will repeat as below for the appropriate number of rows.  

 

If the code you are thinking of could work for up to 10 CPT's per invoice, could we make it such that should it encounter more than ten CPT's on an invoice, it either:

A. retains the allowable 10 lines of data for that invoice

-or-

B. skips the invoice in the report output entirely - but key being that it doesn't cause the script to bomb out?


Thanks!

Joe

 

Current Output - set number of columns 
ORIG_PAYOR_NAMEINVOICE_NUMCPT_CODEAMOUNT
BLUE CROSS314360922021086-1774.92
BLUE CROSS314360922099202-126.43
Aetna314360923031000-1500
Aetna314360923041000-125
Aetna314360923051000-500
Highlighted

@JoeCavasin 
Sorry for the delay. The first two approaches I tried turned out not to be very effective, but I re-grouped and came up with an approach that should be a good starting point. It relies on a procedure to convert rows in a normalized table into columns in a non-normalized table. In order to prevent excessive bloating, I incorporated a previously existing set of functions to create a "scratch" accdb which is deleted at the end. I found that a report in landscape view comfortably accomodated about a dozen CPT Code/Payment Amount pairs. I think you could reduce font size and squeeze one or two more in, but that is the upper limit. If you have to accommodate up to 20 pairs, it would be possible to split them out in a couple of different ways I guess, but I didn't try that. 

See if this works for you.