Solved

Run Time Error 94

Posted on 2013-06-20
11
482 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 119

Expert Comment

by:Rey Obrero
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
 
LVL 119

Expert Comment

by:Rey Obrero
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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 119

Expert Comment

by:Rey Obrero
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 119

Accepted Solution

by:
Rey Obrero 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

760 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now