A
andycambo via AccessMonster.com
Hi,
I'm currently trying to get automatic numbering process created. I'm trying
to use the ELookup function to help with this but I'm not too sure if I have
got it right.
What I am trying to do is trying to find fields with the same number (that is
inputted by the user) and then from the findings find the next number to be
used (they run in order.
For example. The user inputs 060809 (which will get stored in tblMatters
under mDateOfContact). The ELookup function should then find all the fields
with the same date as what the user has inputted. It then checks what unique
numbers are attatched to this records, and then finds the highest number
(mUniqueNumber). If the same mDateOfContact is used then the mUniqueMatter
must be increased by one, if it hasn't been used before then mUniqueMatter
should equal 1.
Here is my code so far.
Private Sub Command35_Click()
Dim intHighestNumber As Integer
Dim dateOfContact As Long
Dim strSQL As String
'store user input for Date Of Contact
dateOfContact = InputBox("Please Enter the First Date of Contact (000000)")
'Finds the next highest unique matters number and adds 1
intHighestNumber = ELookup("[mUniqueMatter]", " tblMatters", "[mDateOfContact]
", "mDateOfContact DESC")
intHighestNumber = intHighestNumber + 1
'Inserts the above findings into the fields in tblMatters
strSQL = "INSERT INTO tblMatters([mDateOfContact],[mUniqueMatter])" & _
"VALUES (dateOfContact, intHighestNumber);"
End Sub
Any help would be much appreciated.
Thanks
Andy.
I'm currently trying to get automatic numbering process created. I'm trying
to use the ELookup function to help with this but I'm not too sure if I have
got it right.
What I am trying to do is trying to find fields with the same number (that is
inputted by the user) and then from the findings find the next number to be
used (they run in order.
For example. The user inputs 060809 (which will get stored in tblMatters
under mDateOfContact). The ELookup function should then find all the fields
with the same date as what the user has inputted. It then checks what unique
numbers are attatched to this records, and then finds the highest number
(mUniqueNumber). If the same mDateOfContact is used then the mUniqueMatter
must be increased by one, if it hasn't been used before then mUniqueMatter
should equal 1.
Here is my code so far.
Private Sub Command35_Click()
Dim intHighestNumber As Integer
Dim dateOfContact As Long
Dim strSQL As String
'store user input for Date Of Contact
dateOfContact = InputBox("Please Enter the First Date of Contact (000000)")
'Finds the next highest unique matters number and adds 1
intHighestNumber = ELookup("[mUniqueMatter]", " tblMatters", "[mDateOfContact]
", "mDateOfContact DESC")
intHighestNumber = intHighestNumber + 1
'Inserts the above findings into the fields in tblMatters
strSQL = "INSERT INTO tblMatters([mDateOfContact],[mUniqueMatter])" & _
"VALUES (dateOfContact, intHighestNumber);"
End Sub
Any help would be much appreciated.
Thanks
Andy.