Solved

Run Time Error 94

Posted on 2013-06-20
11
489 Views
Last Modified: 2013-06-21
I have a parsetext which encounter a run time error 94 when I run the query make table.  

Public Function fnParseText(ParseWhat as Variant, Element as integer, Optional Delimiter as string = ",") as Variant

   Dim myArray() as string

   myArray = Split(ParseWhat, Delimiter)

   if Element < 0 OR Element > ubound(myArray) + 1 then

      fnParseText = NULL

  Else

      fnParseText = myArray(Element - 1)

   End If

End Function


How do I fix this to have the "" returned if it is null?

Hope I didn't cause more confusion.

Always appreciative.
0
Comment
Question by:ammiewinds
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 4
11 Comments
 

Author Comment

by:ammiewinds
ID: 39264626
Just for a little more info, here is the original question:

I have a field that is designed as follows: 
        ??/#######/????????/########/???

I would like to parse the field based on the "/".  The field is not alway consistant, so I would like to have the complete string show in the first parse, if the "/" is not available.

I have been tring the Left$ function:     
     Left$([Field Name],InStr(2,[Field Name],"/")-1)

This was able to bring in the first part.  Yet it gives me an error of "Func!" if the "/" is not in the string and I have not been successful in tring to retrieve the second portion.
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39264689
try this revision

Public Function fnParseText(ParseWhat as Variant, Element as integer, Optional Delimiter as string = ",") as String

   Dim myArray() as string

If Instr(ParseWhat,Delimiter)=0 then
   fnParseText=ParseWhat
   exit function
end if

   myArray = Split(ParseWhat, Delimiter)

   if Element < 0 OR Element > ubound(myArray) + 1 then

      fnParseText = ""

  Else

      fnParseText = myArray(Element - 1)

   End If

End Function
0
 

Author Comment

by:ammiewinds
ID: 39265818
Hello carpricorn1

This returns the first part of the delinited cell in every movement, when the delimiter is not present in the string.

Some of my strings do not contain the delimiter, and I wan them to  show as

        Delimiter Example
           Cell 1                      Cell 2                  Cell 3
           data                       data                     data    

        No Delimiter Example
           Cell 1                      Cell 2                  Cell 3
           data                        no data              no data


When I parse them out I want the strings that do not have a delimiter to enter in the first cell, but not in the second, third...

Any thoughts?
0
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39265851
how is the process done ? give more info./details
0
 

Author Comment

by:ammiewinds
ID: 39265862
Within my Make Table query I have the function set as:

CID 1: fnParseText([Raw Data Granite]![Circuit Name],1"/")
CID 2: fnParseText([Raw Data Granite]![Circuit Name],2,"/")...
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39265967
ok.. use this



Public Function fnParseText(ParseWhat As Variant, Element As Integer, Optional Delimiter As String = ",") As String

   Dim myArray() As String
   myArray = Split(ParseWhat, Delimiter)

   If Element < 0 Or Element > UBound(myArray) + 1 Then
     
     'use this
      fnParseText = "No Data"
     'or
 
'      fnParseText = ""

  Else

      fnParseText = myArray(Element - 1)

   End If

End Function
0
 

Author Comment

by:ammiewinds
ID: 39266031
When I am in my query and use the View, it works.  Yet, when I try to run the Make Table Query I still get the run time error.
0
 

Author Comment

by:ammiewinds
ID: 39266042
It points me to this part of the script for debugging:

myArray = Split(ParseWhat, Delimiter)
0
 

Author Comment

by:ammiewinds
ID: 39266054
When I hover over "ParseWhat"  is shows: "=NULL"

This is the only place i have found NULL in the script.
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 total points
ID: 39266115
oh, so you have a record with no value in field "Circuit Name"

try this revision

Public Function fnParseText(ParseWhat As Variant, Element As Integer, Optional Delimiter As String = ",") As String

if ParseWhat & ""="" then fnParseText="" : exit function

   Dim myArray() As String
   myArray = Split(ParseWhat, Delimiter)

   If Element < 0 Or Element > UBound(myArray) + 1 Then
     
     'use this
      fnParseText = "No Data"
     'or
 
'      fnParseText = ""

  Else

      fnParseText = myArray(Element - 1)

   End If

End Function
0
 

Author Closing Comment

by:ammiewinds
ID: 39266156
Brilliant, Cap!  Thanks so much for your help.   Have a fabulous day!!!
0

Featured Post

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question