Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Compile Error using Dmax funtion

Can any one help me determine why I'm getting a compile error when
using the dmax function?


Dim pk As Long


The line of code
pk = DMax("[OpLogJobDataID]", "tbl_OperatorLogJobData")



Do I need to install a reference or add a public function?


Any help would be appreciated





  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default Compile Error using Dmax funtion

You need to prefix it with WorksheetFunction.

WorksheetFunction.DMax(..., ..., ...)

You'll note that the function requires 3 arguments, not 2 as you've supplied.

For example:
pk = WorksheetFunction.DMax([tbl_OperatorLogJobData], "OpLogJobDataID", [OpLogJobDataID])


Cheers,
Rob


Little Penny wrote:
Can any one help me determine why I'm getting a compile error when
using the dmax function?


Dim pk As Long


The line of code
pk = DMax("[OpLogJobDataID]", "tbl_OperatorLogJobData")



Do I need to install a reference or add a public function?


Any help would be appreciated





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Compile Error using Dmax funtion

Thanks for your reply. I tried the need line of code and now I'm
getting

Runtime error 424

Object required

Any idea?


Little Penny












On Tue, 08 Dec 2009 19:37:54 +1300, Rob van Gelder
wrote:

You need to prefix it with WorksheetFunction.

WorksheetFunction.DMax(..., ..., ...)

You'll note that the function requires 3 arguments, not 2 as you've supplied.

For example:
pk = WorksheetFunction.DMax([tbl_OperatorLogJobData], "OpLogJobDataID", [OpLogJobDataID])


Cheers,
Rob


Little Penny wrote:
Can any one help me determine why I'm getting a compile error when
using the dmax function?


Dim pk As Long


The line of code
pk = DMax("[OpLogJobDataID]", "tbl_OperatorLogJobData")



Do I need to install a reference or add a public function?


Any help would be appreciated





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default Compile Error using Dmax funtion


Check that you have named ranges called tbl_OperatorLogJobData and OpLogJobDataID?

Cheers,
Rob



Little Penny wrote:
Thanks for your reply. I tried the need line of code and now I'm
getting

Runtime error 424

Object required

Any idea?


Little Penny












On Tue, 08 Dec 2009 19:37:54 +1300, Rob van Gelder
wrote:

You need to prefix it with WorksheetFunction.

WorksheetFunction.DMax(..., ..., ...)

You'll note that the function requires 3 arguments, not 2 as you've supplied.

For example:
pk = WorksheetFunction.DMax([tbl_OperatorLogJobData], "OpLogJobDataID", [OpLogJobDataID])


Cheers,
Rob


Little Penny wrote:
Can any one help me determine why I'm getting a compile error when
using the dmax function?


Dim pk As Long


The line of code
pk = DMax("[OpLogJobDataID]", "tbl_OperatorLogJobData")



Do I need to install a reference or add a public function?


Any help would be appreciated





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Compile Error using Dmax funtion




Check that you have named ranges called tbl_OperatorLogJobData and
OpLogJobDataID?




tbl_OperatorLogJobData is a table in my access database and
OpLogJobDataID is the primary key field.


My code

Sub GetMaxKey()

Dim db As Database
Dim rs1 As Recordset
Dim pk As Long

Set db = OpenDatabase("C:\AAAOperatorLog\OperatorLog.mdb")

Set rs1 = db.OpenRecordset("tbl_OperatorLogJobData", dbOpenTable)

'Get max key in from OpLogJobDataID table
pk = Application.WorksheetFunction.DMax([tbl_OperatorLogJobData],
"OpLogJobDataID", [OpLogJobDataID])

rs1.Close

Set rs1 = Nothing

db.Close
Set db = Nothing

Range("A1").Value = pk
End Sub









On Wed, 09 Dec 2009 17:29:29 +1300, Rob van Gelder
wrote:


Check that you have named ranges called tbl_OperatorLogJobData and OpLogJobDataID?

Cheers,
Rob



Little Penny wrote:
Thanks for your reply. I tried the need line of code and now I'm
getting

Runtime error 424

Object required

Any idea?


Little Penny












On Tue, 08 Dec 2009 19:37:54 +1300, Rob van Gelder
wrote:

You need to prefix it with WorksheetFunction.

WorksheetFunction.DMax(..., ..., ...)

You'll note that the function requires 3 arguments, not 2 as you've supplied.

For example:
pk = WorksheetFunction.DMax([tbl_OperatorLogJobData], "OpLogJobDataID", [OpLogJobDataID])


Cheers,
Rob


Little Penny wrote:
Can any one help me determine why I'm getting a compile error when
using the dmax function?


Dim pk As Long


The line of code
pk = DMax("[OpLogJobDataID]", "tbl_OperatorLogJobData")



Do I need to install a reference or add a public function?


Any help would be appreciated







  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Compile Error using Dmax funtion



Sorry typo




Sub GetMaxKey()

Dim db As Database
Dim rs1 As Recordset
Dim pk As Long

Set db = OpenDatabase("C:\AAAOperatorLog\OperatorLog.mdb")

Set rs1 = db.OpenRecordset("tbl_OperatorLogJobData", dbOpenTable)

'Get max key in from OpLogJobDataID field in
tbl_OperatorLogJobData table
pk = Application.WorksheetFunction.DMax([tbl_OperatorLogJobData],
"OpLogJobDataID", [OpLogJobDataID])

rs1.Close

Set rs1 = Nothing

db.Close
Set db = Nothing

Range("A1").Value = pk
End Sub










On Wed, 09 Dec 2009 08:11:35 -0500, Little Penny
wrote:




Check that you have named ranges called tbl_OperatorLogJobData and
OpLogJobDataID?




tbl_OperatorLogJobData is a table in my access database and
OpLogJobDataID is the primary key field.


My code

Sub GetMaxKey()

Dim db As Database
Dim rs1 As Recordset
Dim pk As Long

Set db = OpenDatabase("C:\AAAOperatorLog\OperatorLog.mdb")

Set rs1 = db.OpenRecordset("tbl_OperatorLogJobData", dbOpenTable)

'Get max key in from OpLogJobDataID table
pk = Application.WorksheetFunction.DMax([tbl_OperatorLogJobData],
"OpLogJobDataID", [OpLogJobDataID])

rs1.Close

Set rs1 = Nothing

db.Close
Set db = Nothing

Range("A1").Value = pk
End Sub









On Wed, 09 Dec 2009 17:29:29 +1300, Rob van Gelder
wrote:


Check that you have named ranges called tbl_OperatorLogJobData and OpLogJobDataID?

Cheers,
Rob



Little Penny wrote:
Thanks for your reply. I tried the need line of code and now I'm
getting

Runtime error 424

Object required

Any idea?


Little Penny












On Tue, 08 Dec 2009 19:37:54 +1300, Rob van Gelder
wrote:

You need to prefix it with WorksheetFunction.

WorksheetFunction.DMax(..., ..., ...)

You'll note that the function requires 3 arguments, not 2 as you've supplied.

For example:
pk = WorksheetFunction.DMax([tbl_OperatorLogJobData], "OpLogJobDataID", [OpLogJobDataID])


Cheers,
Rob


Little Penny wrote:
Can any one help me determine why I'm getting a compile error when
using the dmax function?


Dim pk As Long


The line of code
pk = DMax("[OpLogJobDataID]", "tbl_OperatorLogJobData")



Do I need to install a reference or add a public function?


Any help would be appreciated





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Bubble sort Error (Compile Error: Type Mismtach) Excel Monkey[_2_] Excel Programming 6 April 24th 09 12:16 AM
VBAProject name compile error, not defined at compile time Matthew Dodds Excel Programming 1 December 13th 05 07:17 PM
AutoFill Funtion Error DM Excel Programming 3 October 24th 05 01:17 AM
Date Value Funtion in Excel 2003 returns an error, but not in Exce olearyd Excel Worksheet Functions 1 April 13th 05 04:59 PM


All times are GMT +1. The time now is 08:17 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"