C
cemjs via AccessMonster.com
Problem using the DMax function.
1st table named "tblCase" and a field in the table called "AgencyCaseNumber".
2nd table named "tblLead" and a field in that table called "LeadNumber".
On adding a new record (command button) I am trying to get the lead number to
auto - increase by one, but it needs to reset to 1 for each new case number.
I am using a main form called "frmMain" which contains my case number and
then a sub-form on that called "subfrmlead" which contains my lead number and
my command button.
Have been playing with the following code, but unable to get it to work.
DoCmd.GoToRecord , , acNewRec
AllowEdits = True
Me!LeadNumber.DefaultValue = IIf(Nz(DLookup("LeadNumber", "tblLead",
"AgencyCaseNumber = """ & _
Me.Parent!AgencyCaseNumber & """"), 0) = 0, 1, DMax("LeadNumber", "tblLead",
_
"AgencyCaseNumber & = """ & Me.Parent!AgencyCaseNumber & """") + 1)
1st table named "tblCase" and a field in the table called "AgencyCaseNumber".
2nd table named "tblLead" and a field in that table called "LeadNumber".
On adding a new record (command button) I am trying to get the lead number to
auto - increase by one, but it needs to reset to 1 for each new case number.
I am using a main form called "frmMain" which contains my case number and
then a sub-form on that called "subfrmlead" which contains my lead number and
my command button.
Have been playing with the following code, but unable to get it to work.
DoCmd.GoToRecord , , acNewRec
AllowEdits = True
Me!LeadNumber.DefaultValue = IIf(Nz(DLookup("LeadNumber", "tblLead",
"AgencyCaseNumber = """ & _
Me.Parent!AgencyCaseNumber & """"), 0) = 0, 1, DMax("LeadNumber", "tblLead",
_
"AgencyCaseNumber & = """ & Me.Parent!AgencyCaseNumber & """") + 1)