H
Haggr via AccessMonster.com
unconcatenated and concatenated string
Mr said:Haggr,
I am at a loss as to what to tell you.
I have tested the function here with the exact strings that you provided and
the function returns the string values that you show in your examples.
Are you placing a breakpoint in the code to see where the problem may be
occuring.
As I say, when I pass in the "xan72aa-7.5" value, the function returns:
"xan72-7.5".
If I pass in the "xs123pt-e" value, the function returns: "xs123-e".
If this is not what you are wanting to be returned, then I may have
misunderstood.
[quoted text clipped - 209 lines]Having trouble with Rule C, (xan72aa-7.5) returns (xan72) or (xs123pt-e)
returns (xs123).
Haggr via AccessMonster.com said:Your right I posted a message over at Microsoft saying that it did work. I
thought you might see it here also since I seen your reply there.
But Rule A doesn't work.
Ex (xsw124aa) should return (xsw124) or (xsw124waa) should return (xsw124w)
Thanks for all your help. How do you know this stuff, did you write "Access"!
!!
Mr said:Haggr,
I am at a loss as to what to tell you.
I have tested the function here with the exact strings that you provided and
the function returns the string values that you show in your examples.
Are you placing a breakpoint in the code to see where the problem may be
occuring.
As I say, when I pass in the "xan72aa-7.5" value, the function returns:
"xan72-7.5".
If I pass in the "xs123pt-e" value, the function returns: "xs123-e".
If this is not what you are wanting to be returned, then I may have
misunderstood.
[quoted text clipped - 209 lines]Having trouble with Rule C, (xan72aa-7.5) returns (xan72) or (xs123pt-e)
returns (xs123).unconcatenated and concatenated string
Mr said:Haggr,
There was a flaw in the assumptions for Rule A.
I have tested the function below against all of your examples and it returns
values in each case that are equal to your examples.
I have modified the function:
'****Start of Code*****
Public Function fGetFirstChars_Nums_w(pString As Variant) As String
Dim tmp As String
Dim tmpStr As String
Dim strRemStr As String
Dim strNxtChar As String
Dim strPrevChar As String
Dim strW As String
Dim bytChrLoc As Byte
Dim bytWLoc As Byte
Dim bytRemLen As Byte
Dim bytStrLen As Byte
Dim strHyphen As String
Dim cntr
Dim NoNumber As Boolean
Dim NoW As Boolean
'set the values of the flags
NoNumber = False
NoW = False
If Len(Trim(pString & "")) > 0 Then
'rule "B" - if the string contains a "/"
bytChrLoc = InStr(1, pString, "/")
If bytChrLoc > 0 Then
'the following code will loop until the
'previous character is numberic
FindLastNum:
'Character before the "/" must be a number
strPrevChar = Mid(pString, bytChrLoc - 1, 1)
If IsNumeric(strPrevChar) Then
tmp = Left(pString, bytChrLoc - 1)
'next check for any number following the "/"
strRemStr = Right(pString, Len(pString) - bytChrLoc)
bytRemLen = Len(strRemStr)
For cntr = 1 To bytRemLen
strNxtChar = Mid(strRemStr, cntr, 1)
If IsNumeric(strNxtChar) Then
strNxtChar = Mid(strRemStr, cntr, 1)
tmp = tmp + "/" + strNxtChar
GoTo ChkForLetterW
End If
Next cntr
If cntr = bytRemLen + 1 Then
NoNumber = True
End If
ChkForLetterW:
'check to see if the letter "W" exists
'in the remainin g string
bytWLoc = InStr(1, strRemStr, "W")
If bytWLoc > 0 Then
'read the "W" string from the string (no matter
' if it is a capital "W" or not it will still be
' the same character
strW = Mid(strRemStr, bytWLoc, 1)
tmp = tmp + strW
Else
NoW = True
End If
'rule "B-2" - if there is no number following the "/" and
' there is no "W" following the "/"
'use rule "A"
If NoNumber = True And NoW = True Then
GoTo RuleA
End If
'the rules for "B" have been applied and the string is ready
GoTo ReturnString
Else
'try to find the last number in the string
bytChrLoc = bytChrLoc - 1
GoTo FindLastNum
End If
Else
tmp = pString
End If
'rule "C" - if the string contains a "-"
bytChrLoc = InStr(1, tmp, "-")
If bytChrLoc > 0 Then
strHyphen = Right(tmp, Len(tmp) - (bytChrLoc - 1))
tmp = Left(tmp, bytChrLoc - 1)
Else
strHyphen = ""
End If
RuleA:
'rule "A" - String must end with a number except when
' there is a "W" in the string
'find the last numeric value in the string
strPrevChar = Right(tmp, 1)
If IsNumeric(strPrevChar) Then
GoTo ReturnString
Else
bytRemLen = Len(tmp)
For cntr = 1 To bytRemLen
strPrevChar = Mid(tmp, Len(tmp) - cntr, 1)
If IsNumeric(strPrevChar) Then
tmpStr = Left(tmp, Len(tmp) - cntr)
GoTo ChkForExistingW
End If
Next cntr
End If
ChkForExistingW:
bytRemLen = Len(tmp) - Len(tmpStr)
strRemStr = Right(tmp, bytRemLen)
bytWLoc = InStr(1, strRemStr, "W")
If bytWLoc > 0 Then
'read the "W" string from the string (no matter
' if it is a capital "W" or not it will still be
' the same character
strW = Mid(strRemStr, bytWLoc, 1)
tmp = tmpStr + strW
Else
tmp = tmpStr
End If
If strHyphen > "" Then
tmp = tmp + strHyphen
End If
End If
ReturnString:
fGetFirstChars_Nums_w = tmp
End Function
'****End of Code****
And, No, I did not write Access, in fact, I am self-taught in using Access.
I have to give a lot of credit to the other folks who consistantly contribute
to these newsgroups. If it had not been for them and all of their help over
the years, I would never have been able to learn what I know about Access. I
learn something everyday.
[quoted text clipped - 26 lines]Your right I posted a message over at Microsoft saying that it did work. I
thought you might see it here also since I seen your reply there.
Haggr via AccessMonster.com said:You got it. The "Cobol" guys are going to crap. They wanted to help me,
they have that "Root Item Style", but their boss would not allow them to
alter [tabels] and they couldn't figure out how to add that [field] to my
downloadable file (tab-delimited) of all things. You right about one thing,
the people on this and other "Access" sites are totally selfless. Hope you
can help me do some tweaking to this function() "if needed", as the "Cobol"
boys admited, as time went on, they had to get creative to keep adding to
that string. Far as I can see, all "Root Items" are fine. Man if you only
knew how much this helps. Sincerely Thanks.
PS I'm a jewelry manufacturer. All those "aa" "pt" "7.5" refer to the
stones and sizes.
ex (xan72aa-7.5) = Anniversary Ring, AA quality diamonds, size 7.5
or (xmr113/4sy Mothers Ring with 4 stones
And I needed to get to the "root" for billing. Now it is just "scan and
click"
and "W" is White Gold
Thanks again
Mr said:Haggr,
There was a flaw in the assumptions for Rule A.
I have tested the function below against all of your examples and it returns
values in each case that are equal to your examples.
I have modified the function:
'****Start of Code*****
Public Function fGetFirstChars_Nums_w(pString As Variant) As String
Dim tmp As String
Dim tmpStr As String
Dim strRemStr As String
Dim strNxtChar As String
Dim strPrevChar As String
Dim strW As String
Dim bytChrLoc As Byte
Dim bytWLoc As Byte
Dim bytRemLen As Byte
Dim bytStrLen As Byte
Dim strHyphen As String
Dim cntr
Dim NoNumber As Boolean
Dim NoW As Boolean
'set the values of the flags
NoNumber = False
NoW = False
If Len(Trim(pString & "")) > 0 Then
'rule "B" - if the string contains a "/"
bytChrLoc = InStr(1, pString, "/")
If bytChrLoc > 0 Then
'the following code will loop until the
'previous character is numberic
FindLastNum:
'Character before the "/" must be a number
strPrevChar = Mid(pString, bytChrLoc - 1, 1)
If IsNumeric(strPrevChar) Then
tmp = Left(pString, bytChrLoc - 1)
'next check for any number following the "/"
strRemStr = Right(pString, Len(pString) - bytChrLoc)
bytRemLen = Len(strRemStr)
For cntr = 1 To bytRemLen
strNxtChar = Mid(strRemStr, cntr, 1)
If IsNumeric(strNxtChar) Then
strNxtChar = Mid(strRemStr, cntr, 1)
tmp = tmp + "/" + strNxtChar
GoTo ChkForLetterW
End If
Next cntr
If cntr = bytRemLen + 1 Then
NoNumber = True
End If
ChkForLetterW:
'check to see if the letter "W" exists
'in the remainin g string
bytWLoc = InStr(1, strRemStr, "W")
If bytWLoc > 0 Then
'read the "W" string from the string (no matter
' if it is a capital "W" or not it will still be
' the same character
strW = Mid(strRemStr, bytWLoc, 1)
tmp = tmp + strW
Else
NoW = True
End If
'rule "B-2" - if there is no number following the "/" and
' there is no "W" following the "/"
'use rule "A"
If NoNumber = True And NoW = True Then
GoTo RuleA
End If
'the rules for "B" have been applied and the string is ready
GoTo ReturnString
Else
'try to find the last number in the string
bytChrLoc = bytChrLoc - 1
GoTo FindLastNum
End If
Else
tmp = pString
End If
'rule "C" - if the string contains a "-"
bytChrLoc = InStr(1, tmp, "-")
If bytChrLoc > 0 Then
strHyphen = Right(tmp, Len(tmp) - (bytChrLoc - 1))
tmp = Left(tmp, bytChrLoc - 1)
Else
strHyphen = ""
End If
RuleA:
'rule "A" - String must end with a number except when
' there is a "W" in the string
'find the last numeric value in the string
strPrevChar = Right(tmp, 1)
If IsNumeric(strPrevChar) Then
GoTo ReturnString
Else
bytRemLen = Len(tmp)
For cntr = 1 To bytRemLen
strPrevChar = Mid(tmp, Len(tmp) - cntr, 1)
If IsNumeric(strPrevChar) Then
tmpStr = Left(tmp, Len(tmp) - cntr)
GoTo ChkForExistingW
End If
Next cntr
End If
ChkForExistingW:
bytRemLen = Len(tmp) - Len(tmpStr)
strRemStr = Right(tmp, bytRemLen)
bytWLoc = InStr(1, strRemStr, "W")
If bytWLoc > 0 Then
'read the "W" string from the string (no matter
' if it is a capital "W" or not it will still be
' the same character
strW = Mid(strRemStr, bytWLoc, 1)
tmp = tmpStr + strW
Else
tmp = tmpStr
End If
If strHyphen > "" Then
tmp = tmp + strHyphen
End If
End If
ReturnString:
fGetFirstChars_Nums_w = tmp
End Function
'****End of Code****
And, No, I did not write Access, in fact, I am self-taught in using Access.
I have to give a lot of credit to the other folks who consistantly contribute
to these newsgroups. If it had not been for them and all of their help over
the years, I would never have been able to learn what I know about Access. I
learn something everyday.
[quoted text clipped - 26 lines]Your right I posted a message over at Microsoft saying that it did work. I
thought you might see it here also since I seen your reply there.unconcatenated and concatenated string
Mr said:Haggr,
I am very happy to have been able to help. Many other have helped me and
this is just an opportunity to return the favor.
I must admit that I was wondering what those values were and what they could
represent.
Just for the record, I am a contract developer and I work at this everyday.
As I say, I am continually learning everyday.
Again, glad to help.[quoted text clipped - 162 lines]You got it. The "Cobol" guys are going to crap. They wanted to help me,
they have that "Root Item Style", but their boss would not allow them to
Haggr via AccessMonster.com said:Hope your there Mr.B. At work I downloaded my file, the "tab-delimited" from
the "Cobol" guy, Appened it to my [Style] table. Ran the Function() and it
went fine. At the end for the day I download the "tab-delimited" file, tried
append it to [Style] and got error "Numeric Over Flow"
I kind of know that means data mismatch. I going to try to be as detailed as
possible so maybe you can help.
I have a table [Import] linked to a 'tab'delimited" file "import.txt" That .
txt file shows all current activity. I need to need to keep all activity so I
"append" [Import] to a table [Style]. It in in this table that I run the
Function(). [Style] has one extra field that [Import] call [Style].
[MatchString] where the results of the Function() are stored. Below are the
SQL for the append and the functon.
INSERT INTO style ( Job, [Order], Qty, c, Item, [Size], Avl, Type, Due, Age,
[Req'd], [Curr Routing], Sts, Days, Field17, Field18, Field19,,
Field21, Field22, Field23, Ordered, Field25 )
SELECT Import.Job, Import.Order, Import.Qty, Import.c, Import.Item, Import.
Size, Import.Avl, Import.Type, Import.Due, Import.Age, Import.[Req'd], Import.
[Curr Routing], Import.Sts, Import.Days, Import.Field17, Import.Field18,
Import.Field19, Import.Left, Import.Field21, Import.Field22, Import.Field23,
Import.Ordered, Import.Field25
FROM Import;
UPDATE Style SET Style.MatchString = fGetFirstChars_Nums_w([item]);
both tables have all the same propertied and the extra [MatchString].[Style]
has the same propertied as [Import].[Item].
I have been using the append query for awhile and it have been okay, even
using other Functions() to store data in [Style].[MatchString]. I just don't
get it. There is not even a field in [Import] to append to [Style].
[MatchString].
Mr said:Haggr,
I am very happy to have been able to help. Many other have helped me and
this is just an opportunity to return the favor.
I must admit that I was wondering what those values were and what they could
represent.
Just for the record, I am a contract developer and I work at this everyday.
As I say, I am continually learning everyday.
Again, glad to help.[quoted text clipped - 162 lines]You got it. The "Cobol" guys are going to crap. They wanted to help me,
they have that "Root Item Style", but their boss would not allow them tounconcatenated and concatenated string
Mr said:Haggr,
Sorry, I have been out all day and just got back in.
I do not see anytihing right off that woud cause any problem.
The code should be stopping when the error occurs. Try to see if you can
capture the screen where the code stops and email it to me at
(e-mail address removed) (just remove the nospamplease).
You might also place your cursor over some of the variables and other items
to determine the current values that they currenly have. Provide me with as
much info as possible and I'll look at it.[quoted text clipped - 48 lines]Hope your there Mr.B. At work I downloaded my file, the "tab-delimited" from
the "Cobol" guy, Appened it to my [Style] table. Ran the Function() and it
Haggr via AccessMonster.com said:The code runs fine, very fine. But the data it puts into [Style].
[MatchString] somehow cause a "Numeric Over Flow" error when I later I try to
append [Style]. What else causes that error "Numeric Over Flow".
Thank for your help
Mr said:Haggr,
Sorry, I have been out all day and just got back in.
I do not see anytihing right off that woud cause any problem.
The code should be stopping when the error occurs. Try to see if you can
capture the screen where the code stops and email it to me at
(e-mail address removed) (just remove the nospamplease).
You might also place your cursor over some of the variables and other items
to determine the current values that they currenly have. Provide me with as
much info as possible and I'll look at it.[quoted text clipped - 48 lines]Hope your there Mr.B. At work I downloaded my file, the "tab-delimited" from
the "Cobol" guy, Appened it to my [Style] table. Ran the Function() and itunconcatenated and concatenated string
Mr said:Normally you would see this if you tried to assign a value to a numeric type
variable that it could not accept.
That is why I wanted you to try to find out where the error is occuring.
Are you saying that the error is not occurring in the function?[quoted text clipped - 19 lines]The code runs fine, very fine. But the data it puts into [Style].
[MatchString] somehow cause a "Numeric Over Flow" error when I later I try to
Haggr via AccessMonster.com said:Correct not happening in the function, it works great. But after running the
function I cann't append any new records to that table as I could before.
Mr said:Normally you would see this if you tried to assign a value to a numeric type
variable that it could not accept.
That is why I wanted you to try to find out where the error is occuring.
Are you saying that the error is not occurring in the function?[quoted text clipped - 19 lines]The code runs fine, very fine. But the data it puts into [Style].
[MatchString] somehow cause a "Numeric Over Flow" error when I later I try tounconcatenated and concatenated string
Mr said:Are you able to add recrods to the table before running the update with the
function?
I assume that the field you are updating with the function is a text type
field. So, the error you are receiving does not make any sense.
I'm afraid that I do not have any other ideas without actully seeing the
database.
Again, if you would like to send me a copy of it, I will be happy to take a
look at it. I posted my email address in a previous post.[quoted text clipped - 10 lines]Correct not happening in the function, it works great. But after running the
function I cann't append any new records to that table as I could before.
Haggr via AccessMonster.com said:didn''t see the email address. How would it send, it's 256 Mb
Mr said:Are you able to add recrods to the table before running the update with the
function?
I assume that the field you are updating with the function is a text type
field. So, the error you are receiving does not make any sense.
I'm afraid that I do not have any other ideas without actully seeing the
database.
Again, if you would like to send me a copy of it, I will be happy to take a
look at it. I posted my email address in a previous post.[quoted text clipped - 10 lines]Correct not happening in the function, it works great. But after running the
function I cann't append any new records to that table as I could before.unconcatenated and concatenated string
Mr said:Wow, that was larger than I was expecting. Have you compacted it recently?
See if you can reduce the size enough to send it.[quoted text clipped - 14 lines]didn''t see the email address. How would it send, it's 256 Mb
Haggr via AccessMonster.com said:Every time I close it. It' s about seven years old. Probably aproaching one
million records, most is an archive. Alot of backuped tables, like
[Style]. How small do you need it.
Mr said:Wow, that was larger than I was expecting. Have you compacted it recently?
See if you can reduce the size enough to send it.[quoted text clipped - 14 lines]didn''t see the email address. How would it send, it's 256 Mbunconcatenated and concatenated string
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.