Solved

Run Time Error 94

Posted on 2013-06-20
11
496 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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…

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