473,785 Members | 2,816 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do I get code to act on the Value of a field not the literal name

I have a flat file Access database that I am trying to normalize. It has
one collection of fields
named "Project 1 Sponsor & Date" thru "Project 14 Sponsor & Date". These
are essentially freeform fileds. Sometimes the date is in front sometimes
in the middle sometims in the end.
I have a routine done that walks through the up to 254 characters and picks
out the date.
What I am trying to do is walk through the variations of the fieldname and
extract the date piece to put into another file and field.

I have tried:
For index = 1 To 14
RS.MoveFirst
Do While Not RS.EOF
tfGoodDate = False
strFieldID = "RS![Project " & index & " Sponsor & Date]"
If Not IsNull(strField ID) Then
'At this point it I want it to test whether or not the fields value is
null
'but it instead test whether the value of the variable is null.

Any help appreciated.

Thx
Kevin C
Oct 12 '06 #1
6 1469

Kc-Mass wrote:
I have a flat file Access database that I am trying to normalize. It has
one collection of fields
named "Project 1 Sponsor & Date" thru "Project 14 Sponsor & Date". These
are essentially freeform fileds. Sometimes the date is in front sometimes
in the middle sometims in the end.
I have a routine done that walks through the up to 254 characters and picks
out the date.
What I am trying to do is walk through the variations of the fieldname and
extract the date piece to put into another file and field.

I have tried:
For index = 1 To 14
RS.MoveFirst
Do While Not RS.EOF
tfGoodDate = False
strFieldID = "RS![Project " & index & " Sponsor & Date]"
If Not IsNull(strField ID) Then
'At this point it I want it to test whether or not the fields value is
null
'but it instead test whether the value of the variable is null.

Any help appreciated.

Thx
Kevin C
Dim intFieldNo as integer
Dim varFieldID as variant

For intFieldNo = 1 to 14
rs.MoveFirst
Do While Not rs.EOF
fGoodDate=False
varFieldID = rs.Fields("Proj ect" & intFieldNo & "Sponsor &
Date")
If Not IsNull(varField ID) Then
....
End If
rs.MoveNext
Loop

Nexr intFieldNo

Oct 12 '06 #2
Thanks for the suggestion but it is still working just with the variable
and the string assigned to it. It does not reference the field value that
is described by the string at all. Very frustrating - should be simple.
But again thx.

<pi********@hot mail.comwrote in message
news:11******** **************@ i3g2000cwc.goog legroups.com...
>
Kc-Mass wrote:
>I have a flat file Access database that I am trying to normalize. It has
one collection of fields
named "Project 1 Sponsor & Date" thru "Project 14 Sponsor & Date". These
are essentially freeform fileds. Sometimes the date is in front
sometimes
in the middle sometims in the end.
I have a routine done that walks through the up to 254 characters and
picks
out the date.
What I am trying to do is walk through the variations of the fieldname
and
extract the date piece to put into another file and field.

I have tried:
For index = 1 To 14
RS.MoveFirst
Do While Not RS.EOF
tfGoodDate = False
strFieldID = "RS![Project " & index & " Sponsor & Date]"
If Not IsNull(strField ID) Then
'At this point it I want it to test whether or not the fields value
is
null
'but it instead test whether the value of the variable is null.

Any help appreciated.

Thx
Kevin C

Dim intFieldNo as integer
Dim varFieldID as variant

For intFieldNo = 1 to 14
rs.MoveFirst
Do While Not rs.EOF
fGoodDate=False
varFieldID = rs.Fields("Proj ect" & intFieldNo & "Sponsor &
Date")
If Not IsNull(varField ID) Then
....
End If
rs.MoveNext
Loop

Nexr intFieldNo

Oct 12 '06 #3
post the rest of the procedure. It's hard to figure out what's wrong
from here.

Oct 12 '06 #4
"Kc-Mass" <co********@com cast.netwrote in
news:2s******** *************** *******@comcast .com:

Kevin, perhaps you could just loop through the Fields Collectionof your
table.

If you insert this ...

For indes = 0 to 13
Debug.Print index + 1,RS(index).Nam e, RS(index).Value
Next
Stop

.... then in the Immediate window after running you will see the result.

If the Project numbers match, then your code loop 1 to 14 could use just
this:

strFieldID = RS(index - 1).Value

Play with it. Do you see where you can go from there?

For what it's worth, I think your code was failing because Access was
evaluating the String, rather than the Field. I have memories of using
something like ...

Eval("RS![Project " & index & " Sponsor & Date]")

... in Access97, but using the actual Index position is much easier.

Cheers,
Alan

I have a flat file Access database that I am trying to normalize. It
has one collection of fields
named "Project 1 Sponsor & Date" thru "Project 14 Sponsor & Date".
These are essentially freeform fileds. Sometimes the date is in front
sometimes in the middle sometims in the end.
I have a routine done that walks through the up to 254 characters and
picks out the date.
What I am trying to do is walk through the variations of the fieldname
and extract the date piece to put into another file and field.

I have tried:
For index = 1 To 14
RS.MoveFirst
Do While Not RS.EOF
tfGoodDate = False
strFieldID = "RS![Project " & index & " Sponsor & Date]"
If Not IsNull(strField ID) Then
'At this point it I want it to test whether or not the fields
value is
null
'but it instead test whether the value of the variable is null.

Any help appreciated.

Thx
Kevin C

Oct 12 '06 #5
Original message is at bottom.

Here are two versions of the unfinished procedure. The first one attempts
to use the variable and just parses the literal string content of the
variable.

The second is hard coded for the first of the 14 fields. It works perfectly
in so far as it works on the field content and picks out the date every
time.
Any and all help appreciated.

Sub FindDatesinProj ect()

Dim DB As Database

Dim RS As Recordset

Dim strPSD As String

Dim strBuild As String

Dim strDateHold As String

Dim strChar As String

Dim strFieldID As String

Dim tfGoodDate As Boolean

Dim intMark As Integer

Dim intIndex As Integer

Set DB = CurrentDb

Set RS = DB.OpenRecordse t("Project List", dbOpenSnapshot)

tfGoodDate = False

For intIndex = 1 To 5

RS.MoveFirst

Do While Not RS.EOF

strFieldID = "RS![Project " & intIndex & " Sponsor & Date]"

' Debug.Print strFieldID

tfGoodDate = False

If Not IsNull(strField ID) Then

strPSD = strFieldID

If Len(strPSD) 0 Then

Debug.Print strPSD

intMark = 1

strBuild = ""

Do While intMark <= Len(strPSD) And tfGoodDate = False

strChar = Mid(strPSD, intMark, 1)

Do While Not strChar Like "[1,2,3,4,5,6,7,8 ,9,0,/]" And
intMark <= Len(strPSD)

intMark = intMark + 1

strChar = Mid(strPSD, intMark, 1)

Debug.Print strChar

Loop

Do While strChar Like "[1,2,3,4,5,6,7,8 ,9,0,/]" And intMark
<= Len(strPSD)

strBuild = strBuild + strChar

intMark = intMark + 1

strChar = Mid(strPSD, intMark, 1)

Loop

If Len(strBuild) >= 6 And InStr(strBuild, "/") <0 Then

tfGoodDate = True

Else

strBuild = ""

End If

Debug.Print strBuild

Loop

End If

End If

RS.MoveNext

Loop

Next intIndex

End Sub



Sub FindDatesinProj ectNoVariable()

Dim DB As Database

Dim RS As Recordset

Dim strPSD As String

Dim strBuild As String

Dim strDateHold As String

Dim strChar As String

Dim strFieldID As String

Dim tfGoodDate As Boolean

Dim intMark As Integer

Dim intIndex As Integer

Set DB = CurrentDb

Set RS = DB.OpenRecordse t("Project List", dbOpenSnapshot)

tfGoodDate = False

For intIndex = 1 To 5

RS.MoveFirst

Do While Not RS.EOF

strFieldID = RS![Project 1 Sponsor & Date]

tfGoodDate = False

If Not IsNull(RS![Project 1 Sponsor & Date] Then

strPSD = RS![Project 1 Sponsor & Date]

If Len(strPSD) 0 Then

'Debug.Print strPSD

intMark = 1

strBuild = ""

Do While intMark <= Len(strPSD) And tfGoodDate = False

strChar = Mid(strPSD, intMark, 1)

Do While Not strChar Like "[1,2,3,4,5,6,7,8 ,9,0,/]" And
intMark <= Len(strPSD)

intMark = intMark + 1

strChar = Mid(strPSD, intMark, 1)

Debug.Print strChar

Loop

Do While strChar Like "[1,2,3,4,5,6,7,8 ,9,0,/]" And intMark
<= Len(strPSD)

strBuild = strBuild + strChar

intMark = intMark + 1

strChar = Mid(strPSD, intMark, 1)

Loop

If Len(strBuild) >= 6 And InStr(strBuild, "/") <0 Then

tfGoodDate = True

Else

strBuild = ""

End If

Debug.Print strBuild

Loop

End If

End If

RS.MoveNext

Loop

Next intIndex

End Sub
have a flat file Access database that I am trying to normalize. It has
one collection of fields
named "Project 1 Sponsor & Date" thru "Project 14 Sponsor & Date". These
are essentially freeform fileds. Sometimes the date is in front sometimes
in the middle sometims in the end.
I have a routine done that walks through the up to 254 characters and picks
out the date.
What I am trying to do is walk through the variations of the fieldname and
extract the date piece to put into another file and field.

I have tried:
For index = 1 To 14
RS.MoveFirst
Do While Not RS.EOF
tfGoodDate = False
strFieldID = "RS![Project " & index & " Sponsor & Date]"
If Not IsNull(strField ID) Then
'At this point it I want it to test whether or not the fields value is
null
'but it instead test whether the value of the variable is null.

Any help appreciated.

Thx
Kevin C
<pi********@hot mail.comwrote in message
news:11******** **************@ b28g2000cwb.goo glegroups.com.. .
post the rest of the procedure. It's hard to figure out what's wrong
from here.

Oct 13 '06 #6
I thought about the Fields collection and you're probably right that it
would be easier to get the value there. It's hard to believe that VBA
doesn't have the ability to use a variable. Certainly other, older
languages have had that ability.
Also you are right that the procedure is evaluating the the string stored in
the variable rather than the field contents refererred to by the string.
thx

"Alan Carpenter" <No*@iHome.nzwr ote in message
news:Xn******** *************** *@yourdomain.co m...
"Kc-Mass" <co********@com cast.netwrote in
news:2s******** *************** *******@comcast .com:

Kevin, perhaps you could just loop through the Fields Collectionof your
table.

If you insert this ...

For indes = 0 to 13
Debug.Print index + 1,RS(index).Nam e, RS(index).Value
Next
Stop

... then in the Immediate window after running you will see the result.

If the Project numbers match, then your code loop 1 to 14 could use just
this:

strFieldID = RS(index - 1).Value

Play with it. Do you see where you can go from there?

For what it's worth, I think your code was failing because Access was
evaluating the String, rather than the Field. I have memories of using
something like ...

Eval("RS![Project " & index & " Sponsor & Date]")

... in Access97, but using the actual Index position is much easier.

Cheers,
Alan

>I have a flat file Access database that I am trying to normalize. It
has one collection of fields
named "Project 1 Sponsor & Date" thru "Project 14 Sponsor & Date".
These are essentially freeform fileds. Sometimes the date is in front
sometimes in the middle sometims in the end.
I have a routine done that walks through the up to 254 characters and
picks out the date.
What I am trying to do is walk through the variations of the fieldname
and extract the date piece to put into another file and field.

I have tried:
For index = 1 To 14
RS.MoveFirst
Do While Not RS.EOF
tfGoodDate = False
strFieldID = "RS![Project " & index & " Sponsor & Date]"
If Not IsNull(strField ID) Then
'At this point it I want it to test whether or not the fields
value is
null
'but it instead test whether the value of the variable is null.

Any help appreciated.

Thx
Kevin C


Oct 13 '06 #7

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

Similar topics

21
6257
by: AnnMarie | last post by:
<script language="JavaScript" type="text/javascript"> <!-- function validate(theForm) { var validity = true; // assume valid if(frmComments.name.value=='' && validity == true) { alert('Your full name is required. Please enter your full name!'); validity = false; frmComments.name.focus();
6
1882
by: benb | last post by:
I have form that looks a lot like a search bar for the user to search for records matching specified criteria (e.g. first names containing "ben"). For robust results, an intermediary form displays all records matching the criteria (hmm...sound like a popular web site I know). Here is the immediate problem: my code (below) works fine on my computer, but on some of those belonging to my work colleagues (who will be the end users of the db)...
7
8533
by: Donald Grove | last post by:
Is it possible to retrieve field properties from a table in access2000 using code? I have tried: " dim dbs as dao.database dim tbl as dao.tabledef dim fld as dao.field dim prop as dao.property
13
1268
by: Woody Splawn | last post by:
From a Winform I am calling the sub routine that follows in a module Public Sub PopulateWithStates(ByVal myform As Contracts, ByVal FieldName As String) Select Case FieldName Case "txtST" myform.txtST.Items.Clear() myform.txtST.Items.Add("CA") myform.txtST.Items.Add("WA") End Select
4
1552
by: Ganesh Muthuvelu | last post by:
Hello, I was wondering if there is a way to store all the HTML element information in a database and then dynamically generate the HTML code for a page?.. Basically, I do not want to design every HTML page, instead just define the elements like "label", "Textbox", "Submit" button etc., in a database and then have a tool generate the HTML code forme.. Does anyone have any ideas or pointers?? Thanks.
53
4758
by: Hexman | last post by:
Hello All, I'd like your comments on the code below. The sub does exactly what I want it to do but I don't feel that it is solid as all. It seems like I'm using some VB6 code, .Net2003 code, and .Net2005 code. I'm developing in vb.net 2005. This test sub just reads an input text file, writing out records to another text file, eliminating records that have a '99' in them (it is similar to a CSV file). Some of my concerns are:
13
2331
by: frk.won | last post by:
I am interested in learning how to use the VS 2005 code snippets. However, I wish to know what are the best ways to source control the code snippets? Are there any source safe/subversion add-ons for this purpose? If not, any urls which demonstrates code snippets management?
5
1101
by: lawrencef | last post by:
I’m new to JavaScript and am trying to creating a dynamic web form in a number of layers. From what I've read, to submit the entire form I need to have all the fields (that are in all the different layers on the page), present in the main form as hidden fields. I've done this and now and trying to write a function to loop through all the layers on the page and then all the elements within those layers and copy the field value to the hidden...
4
2197
by: tshad | last post by:
I was watching a video that used a code snippet to create a property and when you type "prop" tab tab, it would create the private variable as well as the property definitions with the private variable in it. When you changed the private variable it would also change the variables in the Property definition. But when I do it, I only get the property definition but no variables in it: public int MyProperty { get; set; }
0
9645
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10092
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9950
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
8974
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...
1
7500
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6740
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();...
1
4053
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
3650
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2880
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.