Hi all.
Just a quick question.....
I have a database which is constantly filling up, and a unique "Customer Complaint number" field. mad up from "CCN-xxxx/06" (where xxxx is the identifier.)
I have written a bit of code that accepts claims for different companies via email by searching through my inbox for new atttachments and importing what it finds (from a standard Excel sheet)
Thing is, when I add to my table, I have to find the last (max) "Customer Complaint number", add one and carry on from there.
To do this I have used;
This works fine, and I have no complaints, but to make a query, run it and delete it seems wastefull.
Is there a way of getting this single piece of data other than this?
Ta
Bozzy
Just a quick question.....
I have a database which is constantly filling up, and a unique "Customer Complaint number" field. mad up from "CCN-xxxx/06" (where xxxx is the identifier.)
I have written a bit of code that accepts claims for different companies via email by searching through my inbox for new atttachments and importing what it finds (from a standard Excel sheet)
Thing is, when I add to my table, I have to find the last (max) "Customer Complaint number", add one and carry on from there.
To do this I have used;
Code:
Dim dbs As DAO.Database
Dim qdf As DAO.QueryDef
Dim Updatetable As DAO.Recordset
Dim strSQL As String
Set dbs = CurrentDb
strSQL = "SELECT Last(tblWarrantyData.DEXCCN) AS LastOfDEXCCN FROM tblWarrantyData;"
Set qdf = dbs.CreateQueryDef("qryLastrecord", strSQL)
Set Updatetable = dbs.OpenRecordset("qryLastrecord")
Updatetable.MoveFirst
lastrecord = Updatetable("LastOfDEXCCN")
Updatetable.Close
DoCmd.DeleteObject acQuery, "qryLastrecord"
lastrecord = Mid(lastrecord, 6, (Len(lastrecord) - 8))
This works fine, and I have no complaints, but to make a query, run it and delete it seems wastefull.
Is there a way of getting this single piece of data other than this?
Ta
Bozzy