Stop Function

  • Thread starter mattc66 via AccessMonster.com
  • Start date
M

mattc66 via AccessMonster.com

Hi All,

I have a Function that if fails I want to end all further processes. My
function contains Select Case statements.

I have an Exit Function on Err, but it seems to be looping through the error
over and over again.

Matt
 
M

mattc66 via AccessMonster.com

Public Function ParseData(pstrText As String, _
pintColumn As Integer) As String

On Error GoTo Err_ParseData


Dim arCSV
Dim arX
arCSV = Split(pstrText, ",")
arX = Split(arCSV(1), "x")

Select Case pintColumn
Case 1
ParseData = arCSV(0)
Case 2
ParseData = arX(0)
Case 3
ParseData = arX(1)
Case 4
ParseData = arX(2)
Case 5
ParseData = arCSV(2)
Case 6
ParseData = arCSV(3)


End If


End Select


Exit_ParseData:
Exit Function

Err_ParseData:
MsgBox Err.DESCRIPTION
Resume Exit_ParseData

End Function

Hi Matt -- Post your function...
[quoted text clipped - 5 lines]
 
D

Douglas J. Steele

It would help to know what error message you're getting, but the End If is
definitely wrong and should be removed.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


mattc66 via AccessMonster.com said:
Public Function ParseData(pstrText As String, _
pintColumn As Integer) As String

On Error GoTo Err_ParseData


Dim arCSV
Dim arX
arCSV = Split(pstrText, ",")
arX = Split(arCSV(1), "x")

Select Case pintColumn
Case 1
ParseData = arCSV(0)
Case 2
ParseData = arX(0)
Case 3
ParseData = arX(1)
Case 4
ParseData = arX(2)
Case 5
ParseData = arCSV(2)
Case 6
ParseData = arCSV(3)


End If


End Select


Exit_ParseData:
Exit Function

Err_ParseData:
MsgBox Err.DESCRIPTION
Resume Exit_ParseData

End Function

Hi Matt -- Post your function...
[quoted text clipped - 5 lines]
 
M

mattc66 via AccessMonster.com

I am getting an error because some times the data contains only 2 commas,
because the code is looking for 3. I am sure there is a better way to do what
I am doing, just have not found one that works yet.

Basically I am extracting this data from a legacy order entry system. I need
to take the data and parse it into 6 columns. (The 6th column of data is not
consistent on every line, sometimes there is data and other times its null).

Description Fld
CC, 4.5 x 5 x 7, C2
CC, 4 x 5 x 7, C2
PB, 5.5 x 5.5 x 8, C2, ModelName
CC, 6 x 5 x 7, C6

I am taking this data and parsing it into 5-6 columns:
Fld1
Fld2
Fld3
Fld4
Fld5
Fld6

As you can see by my sample data, sometimes I have the modelName (Fld6) and
sometimes I do not.

I can control to some extent how the data is given to me. Meaning comma's,
the X and etc. I was trying to make it easier for our Order Entry person to
not have to enter the Model name on every order if it was a standard type.

Any help you can give me would be appreciated.

Matt

It would help to know what error message you're getting, but the End If is
definitely wrong and should be removed.
Public Function ParseData(pstrText As String, _
pintColumn As Integer) As String
[quoted text clipped - 40 lines]
 
D

Douglas J. Steele

Case 6
If UBound(arCSV) > 2 Then
ParseData = arCSV(3)
Else
ParseData = vbNullString
End If

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


mattc66 via AccessMonster.com said:
I am getting an error because some times the data contains only 2 commas,
because the code is looking for 3. I am sure there is a better way to do
what
I am doing, just have not found one that works yet.

Basically I am extracting this data from a legacy order entry system. I
need
to take the data and parse it into 6 columns. (The 6th column of data is
not
consistent on every line, sometimes there is data and other times its
null).

Description Fld
CC, 4.5 x 5 x 7, C2
CC, 4 x 5 x 7, C2
PB, 5.5 x 5.5 x 8, C2, ModelName
CC, 6 x 5 x 7, C6

I am taking this data and parsing it into 5-6 columns:
Fld1
Fld2
Fld3
Fld4
Fld5
Fld6

As you can see by my sample data, sometimes I have the modelName (Fld6)
and
sometimes I do not.

I can control to some extent how the data is given to me. Meaning comma's,
the X and etc. I was trying to make it easier for our Order Entry person
to
not have to enter the Model name on every order if it was a standard type.

Any help you can give me would be appreciated.

Matt

It would help to know what error message you're getting, but the End If is
definitely wrong and should be removed.
Public Function ParseData(pstrText As String, _
pintColumn As Integer) As String
[quoted text clipped - 40 lines]

--
Matt Campbell
mattc (at) saunatec [dot] com

Message posted via AccessMonster.com
 
M

mattc66 via AccessMonster.com

That worked without a hitch... Thank you
Case 6
If UBound(arCSV) > 2 Then
ParseData = arCSV(3)
Else
ParseData = vbNullString
End If
I am getting an error because some times the data contains only 2 commas,
because the code is looking for 3. I am sure there is a better way to do
[quoted text clipped - 43 lines]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Compile Error ?? 2
ADODB Question 1
On Error Goto Function 1
Kill files 7
Add an "ALL" option to a Combo Box 0
msgbox customise 6
Passing Function a Variable 4
DlookUp Help 6

Top