Results 1 to 15 of 15
  1. #1
    dongodu is offline Novice
    Windows XP Access 2003
    Join Date
    May 2011
    Posts
    11

    Run Time Error '94'


    Code:
    Function autogen() As String
        Dim cnview As New ADODB.connection
       Dim rsview As New ADODB.Recordset
    
    Call connection(cnview, App.Path & "\Medrar.mdb", "endromida")
    'Call connection(cnview, "\\mika\medrar\Medrar.mdb", "endromida")
    Call Recordset(rsview, cnview, "SELECT max(cusno)FROM Customer")
    
        If rsview.EOF Or Not Null Then
            autogen = "C-0000"
              Else
            autogen = "C-" & Format(Right$(Trim$(rsview(0)), 4) + 1, "0000") --> In this Lines
        End If
        
    End Function

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716
    Is there a question?
    Do you have code for functions Connection and recordset?
    Have you considered using Error handling, or some debugging statements to assist in solving/pinpointing the problem?

    Perhaps you could provide some context of the issue to help us understand what you are asking.

  3. #3
    Stingaway is offline Efficiency Junkie
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2011
    Location
    The deep south. Keep going until you hit water basically.
    Posts
    224
    Orange, you ask too much.

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716
    Quote Originally Posted by Stingaway View Post
    Orange, you ask too much.
    I see you didn't respond to dongodu, did you understand the question?

  5. #5
    Stingaway is offline Efficiency Junkie
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2011
    Location
    The deep south. Keep going until you hit water basically.
    Posts
    224
    Nope, I had the same thought... I didn't actually see a question.

  6. #6
    dongodu is offline Novice
    Windows XP Access 2003
    Join Date
    May 2011
    Posts
    11
    Not using any codes for Recordset and no Error Handles

  7. #7
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716
    Quote Originally Posted by dongodu View Post
    Not using any codes for Recordset and no Error Handles
    Do you have a specific question/issue? If so, could you describe what it is?

    If it is error 94 Invalid use of Null, you could try googling it.

    You could also look up NZ() in the Access help.

  8. #8
    dongodu is offline Novice
    Windows XP Access 2003
    Join Date
    May 2011
    Posts
    11
    My question is when i try enter Record in that table by using VB application, it shows Run time Error '94' Invalid Use of Null?
    How to resolve this error???/

  9. #9
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716
    Put some breakpoints in your code, and step through it using F8.
    See which line it is failing on.
    That line will have some expression where you have a NULL.

    You can adjust the line using Nz(variableName,0)

    See this for more info
    http://www.vbforums.com/showthread.php?t=401834

  10. #10
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    First thing to look at is this line:

    If rsview.EOF Or Not Null Then

    Not Null is not a valid check there. And what is it you really want to check? I think you would want

    If rsview.BOF AND rsview.EOF Then

    Which would mean that there is no record returned and therefore you would want the start number.

  11. #11
    dongodu is offline Novice
    Windows XP Access 2003
    Join Date
    May 2011
    Posts
    11
    My question is when i try enter 1st Record in that table by using VB application, it shows Run time Error '94' Invalid Use of Null?
    How to resolve this error???


  12. #12
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716
    Did you try suggestions given in post#9 and #10?
    What were the results?

  13. #13
    dongodu is offline Novice
    Windows XP Access 2003
    Join Date
    May 2011
    Posts
    11
    Same result

  14. #14
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716
    Really?
    Put a breakpoint on
    Call connection(cnview, App.Path & "\Medrar.mdb", "endromida")
    then start stepping through your code, F8 one line at a time

    I tried to simulate your issue ( but I have no idea what values could be in rsview(0) )

    Code:
    Sub Oct22()
    
    '"C-" & Format(Right$(Trim$(rsview(0)), 4) + 1, "0000")
    Dim rsview As String
    rsview = "0 " '"00000" '"7777777" 'vbnullstring
    Debug.Print Trim$(rsview)
    Debug.Print Right$(Trim$(rsview), 4) + 1
    Debug.Print "C-" & Format(Right$(Trim$(rsview), 4) + 1, "0000")
    End Sub
    But I could not make this fail with error 94; the best I could do is Error 13 type mismatch.

    You might try to look at the values in rsview(0) and see if you have a NULL???

  15. #15
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716
    Managed to get error 94
    Sub Oct22Err94()

    '"C-" & Format(Right$(Trim$(rsview(0)), 4) + 1, "0000")
    Dim rsview As Variant
    rsview = Null '"0 " '"00000" '"7777777" 'vbnullstring
    Debug.Print Trim$(rsview)
    Debug.Print Right$(Trim$(rsview), 4) + 1
    Debug.Print "C-" & Format(Right$(Trim$(rsview), 4) + 1, "0000")
    End Sub
    Seems only a Variant can contain a Null value, and you can assign NULL to a variable

    Here's a way around the error 94 in my test, where rsview is the issue.

    Sub Oct22NoErr94()

    '"C-" & Format(Right$(Trim$(rsview(0)), 4) + 1, "0000")
    Dim rsview As Variant
    rsview = Null '"0 " '"00000" '"7777777" 'vbnullstring
    Debug.Print Trim$(Nz(rsview, 0))
    Debug.Print Right$(Trim$(Nz(rsview, 0)), 4) + 1
    Debug.Print "C-" & Format(Right$(Trim$(Nz(rsview, 0)), 4) + 1, "0000")
    End Sub
    Good luck

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Error in Run Time
    By dongodu in forum Queries
    Replies: 5
    Last Post: 07-24-2011, 06:54 PM
  2. Replies: 2
    Last Post: 12-23-2010, 09:11 AM
  3. Replies: 2
    Last Post: 12-02-2010, 02:35 AM
  4. Run time error
    By vaikz in forum Import/Export Data
    Replies: 1
    Last Post: 02-18-2010, 11:37 PM
  5. Run Time Error 424
    By ddog171 in forum Programming
    Replies: 3
    Last Post: 02-04-2006, 07:13 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums