Link to home
Start Free TrialLog in
Avatar of Sandesh555
Sandesh555Flag for India

asked on

Use of DMax in Excel not working./

Hi Team,

the given below code is not working form me.  Can you please help.

Private Sub RecTimeAddition()
    'Database Declariation
    Dim db As DAO.Database
    Dim rs As DAO.Recordset
    Dim dblDocID As Double

    'Database Connection
    Set db = OpenDatabase("DatebasePath.mdb")
    Set rs = db.OpenRecordset("tblRecevied", dbOpenTable)
    
    'Get the Doc ID
    dblDocID = DMax("rs.[tblRecevied].[DocID]", "rs.[tblRecevied]")

End Sub

Open in new window

Avatar of Jorge Paulino
Jorge Paulino
Flag of Portugal image

Try this way:


dblDocID = DMax(rs.[tblRecevied].[DocID], rs.[tblRecevied])


Note: That way you are not getting the results from the recordset for the DMAX function but using that as strings
ASKER CERTIFIED SOLUTION
Avatar of IrogSinta
IrogSinta
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
As I understand it (I've never used it) DMAX works on a "database" consisting of a range of cells in Excel, rather than an Access database. Here's an example.
Looking at the code I gave you and the one you provided, I see you have tblReceived spelled as tblRecevied, so you need to adjust accordingly.