Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 1 / February 2007

Tip: Looking for answers? Try searching our database.

Determine if New or Repeat Client

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jana - 27 Feb 2007 15:17 GMT
Good morning, Access gurus!

I'm having a brain fart and can't seem to wrap my head around the
logic for this problem, so I'm hoping someone out there can help me
out.  Here's my situation:

I have a table of debts placed by clients (we're a collection agency).
tblDebts:
DebtID (autonumber pk)
ClientID (string)
ListDate (date)
ListAmt (double)

What I need to determine is whether a debt is considered New Business
or Repeat Business.  A function that returns a boolean (e.g.
CountAsNewBiz) would be fine for my purposes.  A new client placement
is either a) a placement by a client who's never placed with us
before; or b) a placement by a client who hasn't placed a debt in over
a year.  We then have an activation period of 30 days in which we
count any placements as New Business.  Once the 30 days expires,
placements are considered Repeat Business.

Here are a few examples:
ClientID 1234A places a debt on 01/15/07 for $100.  They have never
placed with us before, so any placements listed between 01/15/07 and
02/14/07 should be considered as New Business.

ClientID 3456B places a debt on 01/15/07 for $100.  The first time
this client placed with us was 12/31/02.  They have been continuously
placing over the years, and last placed a debt on 01/12/07.  This
placement should be considered as Repeat Business.

ClientID 56789C places a debt on 01/15/07 for $100.  The first time
this client placed with us was 12/31/02.  The last time this client
placed with us was 12/31/05, so there has been a gap of over a year.
This placement should be considered New Business.

ClientID 56789C now places another debt on 01/20/07 for $150.  Since
01/15/07's placement was considered New Business and it's between
01/15/07 and 02/14/07, this debt is also considered New Business.
Anything placed after 02/14/07 would be Repeat Business.

If my explanation is unclear, please let me know.

Thanks in advance for your suggestions,
Jana
DavidB - 27 Feb 2007 16:36 GMT
Prior Activity (Y/N)?
 If N then NEW.

 If Y then...

Activity within the last 30 days (Y/N)?
 If Y then...
   Prior Activity > 30 days old (Y/N)?
     If Y then Repeat.
     If N then NEW.

 If N then...

Activity within last year (Y/N)?
 If Y then REPEAT.
 If N then NEW.

Thats my best guess anyway...

> Good morning, Access gurus!
>
[quoted text clipped - 42 lines]
> Thanks in advance for your suggestions,
> Jana
Jana - 27 Feb 2007 16:57 GMT
> Prior Activity (Y/N)?
>   If N then NEW.
[quoted text clipped - 63 lines]
>
> - Show quoted text -

Thanks, I'll give it a shot.
Jana - 27 Feb 2007 23:44 GMT
> > Prior Activity (Y/N)?
> >   If N then NEW.
[quoted text clipped - 67 lines]
>
> - Show quoted text -

David:

Thanks very much for your assistance! Here's what I came up with as my
final function (I still need to add error handling and clean up my
naming).  I'm doing a reality check on my results, but so far I
haven't found any anomalies:

Function isNew(CltID As String, LD As Date) As Boolean
Dim potFirstAD
Dim lst30 As Date
Dim AD As Date
lst30 = LD - 30
Select Case DCount("[LIST_DATE]", "DEBT", "[CLT_ID] = '" & CltID & "'
and [LIST_DATE] >= #" & lst30 & "#")
Case 0
   'No biz in past 30 days
   potFirstAD = LD
Case Is > 0
   potFirstAD = CDate(DMin("[LIST_DATE]", "DEBT", "[CLT_ID] = '" &
CltID & "' and [LIST_DATE] >= #" & lst30 & "#"))
End Select
AD = DMin("[LIST_DATE]", "DEBT", "[CLT_ID] = '" & CltID & "' and
[LIST_DATE] BETWEEN #" & potFirstAD - 365 & "# AND #" & potFirstAD &
"#")
If LD - AD <= 30 Then
   isNew = True
Else
   isNew = False
End If
End Function

Once again, this group is a fabulous resource.

Jana
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.