Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Run Time Error 94

Posted on 2013-06-20
11
Medium Priority
?
509 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
  • 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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 2000 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

916 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