J
jbiggs via AccessMonster.com
I am trying to do a Dlookup for the number of leads and date from a table.
If it is not today's date, then a new entry is created with the lead count =
0. The problem is that every user just keep incrementing the top entry if
the date is correct instead of finding the correct ID#. Here is the code:
RepNumber = DLookup("[Rep Number]", "Debt Advisors", "username = CurrentUser")
RepLeads = DLookup("[leads]", "fresh lead counter", [Salesperson] = RepNum)
Yesterday = date - 1
If RepLeads = Null Then
stDocName = "fresh lead counter"
stLinkCriteria = [Salesperson] = Me![Combo21]
DoCmd.OpenForm stDocName, , , stLinkCriteria
Forms![fresh lead counter]![leads] = 0
Forms![fresh lead counter]![todaysdate] = Yesterday
Forms![fresh lead counter]![Salesperson] = RepNum
DoCmd.Close
End If
whatday = DLookup("[todaysdate]", "fresh lead counter", [Salesperson] =
RepNum)
If whatday < date Then
stDocName = "fresh lead counter"
stLinkCriteria = [Salesperson] = Me![Combo21]
DoCmd.OpenForm stDocName, , , stLinkCriteria
Forms![fresh lead counter]![leads] = 0
Forms![fresh lead counter]![todaysdate] = date
Forms![fresh lead counter]![Salesperson] = RepNum
DoCmd.Close
End If
howmany = DLookup("[leads]", "fresh lead counter", [Salesperson] = RepNum)
maxleads = DLookup("[fresh leads per day]", "Debt Advisors",
"Username=CurrentUser")
If howmany < maxleads Then
DoCmd.OpenForm ("unasigned new leads2")
DoCmd.GoToRecord , , acFirst
Forms![unasigned new leads2]![Salesperson] = RepNum
DoCmd.Close
stDocName = "fresh lead counter"
stLinkCriteria = [Salesperson] = Me![Combo21]
DoCmd.OpenForm stDocName, , , stLinkCriteria
Forms![fresh lead counter]![leads] = howmany + 1
Forms![fresh lead counter]![todaysdate] = date
DoCmd.Close
End If
If it is not today's date, then a new entry is created with the lead count =
0. The problem is that every user just keep incrementing the top entry if
the date is correct instead of finding the correct ID#. Here is the code:
RepNumber = DLookup("[Rep Number]", "Debt Advisors", "username = CurrentUser")
RepLeads = DLookup("[leads]", "fresh lead counter", [Salesperson] = RepNum)
Yesterday = date - 1
If RepLeads = Null Then
stDocName = "fresh lead counter"
stLinkCriteria = [Salesperson] = Me![Combo21]
DoCmd.OpenForm stDocName, , , stLinkCriteria
Forms![fresh lead counter]![leads] = 0
Forms![fresh lead counter]![todaysdate] = Yesterday
Forms![fresh lead counter]![Salesperson] = RepNum
DoCmd.Close
End If
whatday = DLookup("[todaysdate]", "fresh lead counter", [Salesperson] =
RepNum)
If whatday < date Then
stDocName = "fresh lead counter"
stLinkCriteria = [Salesperson] = Me![Combo21]
DoCmd.OpenForm stDocName, , , stLinkCriteria
Forms![fresh lead counter]![leads] = 0
Forms![fresh lead counter]![todaysdate] = date
Forms![fresh lead counter]![Salesperson] = RepNum
DoCmd.Close
End If
howmany = DLookup("[leads]", "fresh lead counter", [Salesperson] = RepNum)
maxleads = DLookup("[fresh leads per day]", "Debt Advisors",
"Username=CurrentUser")
If howmany < maxleads Then
DoCmd.OpenForm ("unasigned new leads2")
DoCmd.GoToRecord , , acFirst
Forms![unasigned new leads2]![Salesperson] = RepNum
DoCmd.Close
stDocName = "fresh lead counter"
stLinkCriteria = [Salesperson] = Me![Combo21]
DoCmd.OpenForm stDocName, , , stLinkCriteria
Forms![fresh lead counter]![leads] = howmany + 1
Forms![fresh lead counter]![todaysdate] = date
DoCmd.Close
End If