473,811 Members | 3,640 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Access2K: Extract a string

This a a long convoluted string parsing question...
I have a string in an Access 2K database table field that I use for
noting if a user has checked a record.
The string goes like this:
x[UserID]y
So the field looks like this:
x123yx456yx543y and so on...

I run a LIKE query when the form loads to determine the state of
control CheckBox indicating if the user has checked the record:

If Forms!myFrmName .CheckList Like "*x" & UserID & "y*" Then
Forms!myFrmName .CheckBox = True
Else
Forms!myFrmName .CheckBox = False
End If

I run a string of code to remove the x[UserID]y string from field
Checklist if the current user unchecks the control CheckBox.

So far so good.

The system works fine, but now I want to include another variable, so
that the
string would go like this:
x[UserID]y[OneorTwoDigitNu mber]z
The field would look like this:
x123y3zx456y14z x543y7z and so on...

So here's the question...
I can still search for Forms!myFrmName .CheckList Like "*x" & UserID &
"y*" to check or uncheck the CheckBox control.
But how do I extract:
Forms!myFrmName .CheckList Like "*x" & UserID & "y" & ?? & "z*"
I will know "x123y" but how can I determine what follows "y" before
"z"?

(I know this could be done by creating a table creating a new record
linking users and records in the old table, but I want to stick with
this system for this particular use...)

Any help is appreciated...
lq
Nov 12 '05 #1
3 1781

"Lauren Quantrell" <la************ *@hotmail.com> escreveu na mensagem
news:47******** *************** ***@posting.goo gle.com...
This a a long convoluted string parsing question...
I have a string in an Access 2K database table field that I use for
noting if a user has checked a record.
The string goes like this:
x[UserID]y
So the field looks like this:
x123yx456yx543y and so on...

I run a LIKE query when the form loads to determine the state of
control CheckBox indicating if the user has checked the record:

If Forms!myFrmName .CheckList Like "*x" & UserID & "y*" Then
Forms!myFrmName .CheckBox = True
Else
Forms!myFrmName .CheckBox = False
End If

I run a string of code to remove the x[UserID]y string from field
Checklist if the current user unchecks the control CheckBox.

So far so good.

The system works fine, but now I want to include another variable, so
that the
string would go like this:
x[UserID]y[OneorTwoDigitNu mber]z
The field would look like this:
x123y3zx456y14z x543y7z and so on...

So here's the question...
I can still search for Forms!myFrmName .CheckList Like "*x" & UserID &
"y*" to check or uncheck the CheckBox control.
But how do I extract:
Forms!myFrmName .CheckList Like "*x" & UserID & "y" & ?? & "z*"
I will know "x123y" but how can I determine what follows "y" before
"z"?

(I know this could be done by creating a table creating a new record
linking users and records in the old table, but I want to stick with
this system for this particular use...)

Any help is appreciated...
lq


Hi,

Dim searchSTR as String
Dim start as Integer
Dim OneorTwoDigitNu mber as Integer
....
searchSTR = "x" & UserID & "y"
start = InStr(1, Forms!myFrmName .CheckList, searchSTR)

If start > 0 Then

OneorTwoDigitNu mber = Val( Mid (Forms!myFrmNam e.CheckList, start +
Len(searchSTR) ) )

Forms!myFrmName .CheckBox = True
Else
Forms!myFrmName .CheckBox = False
End If

HTH
Roberto
Nov 12 '05 #2
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

You stated the solution in your question. Use the wildcard character
"?" (question-mark) to indicate the 2 unknown characters between y and
z. E.g.:

If Forms!myFrmName .CheckList Like "*x" & UserID & "y??z*" Then
HTH,

MGFoster:::mgf0 0 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQAROoIechKq OuFEgEQLmUQCgvb/C9zoMQXBk2SPty1 pN0Qv/kdcAnRcC
7GGFJp/GmY3DMm60T4Vxzq kF
=H6My
-----END PGP SIGNATURE-----
Lauren Quantrell wrote:
This a a long convoluted string parsing question...
I have a string in an Access 2K database table field that I use for
noting if a user has checked a record.
The string goes like this:
x[UserID]y
So the field looks like this:
x123yx456yx543y and so on...

I run a LIKE query when the form loads to determine the state of
control CheckBox indicating if the user has checked the record:

If Forms!myFrmName .CheckList Like "*x" & UserID & "y*" Then
Forms!myFrmName .CheckBox = True
Else
Forms!myFrmName .CheckBox = False
End If

I run a string of code to remove the x[UserID]y string from field
Checklist if the current user unchecks the control CheckBox.

So far so good.

The system works fine, but now I want to include another variable, so
that the
string would go like this:
x[UserID]y[OneorTwoDigitNu mber]z
The field would look like this:
x123y3zx456y14z x543y7z and so on...

So here's the question...
I can still search for Forms!myFrmName .CheckList Like "*x" & UserID &
"y*" to check or uncheck the CheckBox control.
But how do I extract:
Forms!myFrmName .CheckList Like "*x" & UserID & "y" & ?? & "z*"
I will know "x123y" but how can I determine what follows "y" before
"z"?

(I know this could be done by creating a table creating a new record
linking users and records in the old table, but I want to stick with
this system for this particular use...)

Any help is appreciated...
lq


Nov 12 '05 #3
Tym
On 13 Jan 2004 10:19:59 -0800, la************* @hotmail.com (Lauren
Quantrell) wrote:
If Forms!myFrmName .CheckList Like "*x" & UserID & "y*" Then
Forms!myFrmName .CheckBox = True
Else
Forms!myFrmName .CheckBox = False
End If


Something like this???

Dim iPos as Integer
Dim zStart as Integer
dim zLength as Integer

iPos = 0

iPos = instr(Forms!myF rmName.CheckLis t,"y",1)

if iPos then

if mid(Forms!myFrm Name.CheckList, ipos+2,1) = "z" or
mid(Forms!myFrm Name.CheckList, ipos+3,1) = "z" then
'y??z found
zstart =
instr(Forms!myF rmName.CheckLis t,"z",instr(For ms!myFrmName.Ch eckList,"y",1))
zLength = instr(Forms!myF rmName.CheckLis t,"y",1),zSta rt

OneOrTwoDigitNu mber = mid
(Forms!myFrmNam e.CheckList,zSt art,zLength)
Endif


Nov 12 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
16991
by: Sharon | last post by:
hi, I want to extract a string from a file, if the file is like this: 1 This is the string 2 3 4 how could I extract the string, starting from the 10th position (i.e. "T") and extract 35 characters (including "T") from a file and then go to next line?
4
2940
by: Chris | last post by:
I am calling a COM object that returns a type Object and it contains two strings but I can't get them out. Here is the command: object ParamNameObj= localxPCCOMOBJ.xPCTarget.GetParamName (1); ParamNameObj shows up as a System.Array in the watch window with the following elements. - datastr1 as string
12
4171
by: rshepard | last post by:
I'm a bit embarrassed to have to ask for help on this, but I'm not finding the solution in the docs I have here. Data are assembled for writing to a database table. A representative tuple looks like this: ('eco', "(u'Roads',)", 0.073969887301348305) Pysqlite doesn't like the format of the middle term: pysqlite2.dbapi2.InterfaceError: Error binding parameter 1 - probably
8
2482
by: zadkiel | last post by:
hi all. I got a urgent problem in my job. the sample data as follows: FT="EXERPRI:$68.88/10W*BB9505-28765710" FT="MEETON6/3/07FOR What I need is to extract the string after the quote and before any punctuation or integer so my outcome can be like this:
1
4578
by: rcamarda | last post by:
I'd need to have a function that allows me to extract 'fields' from within the string I.E. (kinda pseudo code) declare @foo as varchar(100) set @foo = "Robert*Camarda*123 Main Street" select EXTRACT(@foo, '*', 2) ; -- would return 'Camarda' select EXTRACT(@foo, '*', 3) ;-- returns '123 Main Street' select EXTRACT(@foo, '*', 0) ;-- would return entire string select EXTRACT(@foo,'*' , 9) ;-- would return null
1
1969
by: AccessHunter | last post by:
Hi, Please help as this is urgent. I have the following data in a column. In the report I want to display them only with whatever is before the "-". A SECOND DAY, INC.-FORMAT 4 A SECOND ADY, INC-VERSION 1 A SECOND DAY,INC.-VERSION 1 CLAIR FOUNDATION - OPTION 1
1
1529
by: josephtys86 | last post by:
203.114.10.66 - - "GET /stat.gif? stat=v&c=F-Secure&v=1.1%20Build%2014231&s=av%7BNorton %20360%20%28Symantec%20Corporation%29+69%3B%7Dsw%7BNorton %20360%20%28Symantec%20Corporation%29+69%3B%7Dfw%7BNorton %20360%20%28Symantec%20Corporation%29+5%3B%7Dv%7BMicrosoft%20Windows %20XP+insecure%3BMicrosoft%20Windows%20XP%20Professional+f %3B26027%3B26447%3B26003%3B22452%3B%7D&r=0.9496 HTTP/1.1" 200 43...
1
2733
by: Edwin.Madari | last post by:
from each line separate out url and request parts. split the request into key-value pairs, use urllib to unquote key-value pairs......as show below... import urllib line = "GET...
0
1679
by: javaBookWorm | last post by:
203.114.10.66 - - "GET /stat.gif?stat=v&c=F-Secure&v=1.1%20Build%2014231&s=av%7BNorton%20360%20%28Symantec%20Corporation%29+69%3B%7Dsw%7BNorton%20360%20%28Symantec%20Corporation%29+69%3B%7Dfw%7BNorton%20360%20%28Symantec%20Corporation%29+5%3B%7Dv%7BMicrosoft%20Windows%20XP+insecure%3BMicrosoft%20Windows%20XP%20Professional+f%3B26027%3B26447%3B26003%3B22452%3B%7D&r=0.9496 HTTP/1.1" 200 43...
0
10647
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10384
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10130
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9204
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6887
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5692
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4338
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3865
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3017
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.