+ Reply to Thread
Results 1 to 2 of 2

Invalid use of null

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    02-20-2009
    Location
    bristol
    MS-Off Ver
    Excel 2003
    Posts
    882

    Invalid use of null

    Hi uys

    My access table is empty. If I want to know whats the maximum ID value in the table in future then I use the following code:

    ID is autonumber field. In order to check if there is no record in the table or when ID is null then what code can be inserted in this? Thanks

    Private Sub CommandButton1_Click()
    Dim cn As ADODB.Connection
    Dim rs As ADODB.Recordset
    Dim ws1 As Worksheet
    Dim r, i, Sum As Long
    
        Set cn = New ADODB.Connection
        cn.Open "Provider=Microsoft.Jet.OLEDB.4.0; " & _
            "Data Source=J:\Work.mdb;"
        Set rs = CreateObject("ADODB.Recordset")
        
        strsql = "select max(id) from ZBatchTBL"
        
        rs.Open strsql, cn
        i = rs.Fields(0)
        MsgBox i
            
            rs.Close
        
        Exit Sub

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: Invalid use of null

    Have you tried using Count instead of Max?
    ]
    If posting code please use code tags, see here.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Invalid use of null error
    By aman1234 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-01-2013, 06:16 AM
  2. [SOLVED] Run-time error 94; Invalid use of Null
    By williams485 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-29-2012, 09:36 AM
  3. [SOLVED] Invalid Use of Null - Formating listbox column
    By chinaboy in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-24-2012, 02:48 PM
  4. [SOLVED] VBA - runtime error 94, invalid use of null
    By arneld in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-25-2012, 06:46 PM
  5. Run Time Error: 94 (invalid use of null)
    By jason_kelly in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-14-2012, 02:06 PM
  6. Invalid use of null error
    By aman1234 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-13-2011, 04:41 AM
  7. Run Time Error '94' Invalid use of null
    By stoey in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 11-28-2008, 05:44 AM
  8. invalid use of null
    By mxp in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-01-2007, 09:33 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1