473,396 Members | 1,767 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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[OneorTwoDigitNumber]z
The field would look like this:
x123y3zx456y14zx543y7z 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 1754

"Lauren Quantrell" <la*************@hotmail.com> escreveu na mensagem
news:47**************************@posting.google.c om...
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[OneorTwoDigitNumber]z
The field would look like this:
x123y3zx456y14zx543y7z 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 OneorTwoDigitNumber as Integer
....
searchSTR = "x" & UserID & "y"
start = InStr(1, Forms!myFrmName.CheckList, searchSTR)

If start > 0 Then

OneorTwoDigitNumber = Val( Mid (Forms!myFrmName.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:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

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

iQA/AwUBQAROoIechKqOuFEgEQLmUQCgvb/C9zoMQXBk2SPty1pN0Qv/kdcAnRcC
7GGFJp/GmY3DMm60T4VxzqkF
=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[OneorTwoDigitNumber]z
The field would look like this:
x123y3zx456y14zx543y7z 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!myFrmName.CheckList,"y",1)

if iPos then

if mid(Forms!myFrmName.CheckList,ipos+2,1) = "z" or
mid(Forms!myFrmName.CheckList,ipos+3,1) = "z" then
'y??z found
zstart =
instr(Forms!myFrmName.CheckList,"z",instr(Forms!my FrmName.CheckList,"y",1))
zLength = instr(Forms!myFrmName.CheckList,"y",1),zStart

OneOrTwoDigitNumber = mid
(Forms!myFrmName.CheckList,zStart,zLength)
Endif


Nov 12 '05 #4

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

Similar topics

9
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...
4
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); ...
12
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...
8
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...
1
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...
1
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...
1
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...
1
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
by: javaBookWorm | last post by:
203.114.10.66 - - "GET...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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,...
0
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...
0
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...
0
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,...

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.