Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Bubble sort Error (Compile Error: Type Mismtach) | Excel Programming | |||
VBAProject name compile error, not defined at compile time | Excel Programming | |||
AutoFill Funtion Error | Excel Programming | |||
Date Value Funtion in Excel 2003 returns an error, but not in Exce | Excel Worksheet Functions |