Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Determining the contents of a DataField 2

Status
Not open for further replies.

usakjw

Programmer
Sep 8, 2005
47
US
Is it possible to determine the contents of a data field in a recordset. I have a DataField that will have one of three entries. Depending on what will be in the DataField, Information will be written to one of three word documents.

KJW
 
Not sure precisely what you mean but if the field is called "DocumentName" you can reference:
Code:
If Rs!DocumentName="Document1" Then ...
Code:
If Rs.Fields("DocumentName")="Document1" Then ...
 
I have a .mdb file that has 71 fields, however I only want some of that information if one of the fields contain one of three possible entries. If this field contains the entry I'm looking for then information in other fields is formated and put into a word document.

The name of my document is VoterInfo.mdb
The nam of the field is Precint

What is this Rs! I have not seen this in VB before.





KJW
 
! is just a quick way to access the recordset's fields. Instead of typing Rs.fields("FieldName").value you can just type Rs!FieldName to get to the field value.
-Max
 
Fields is the default property of the recordset object so...

RS!DocumentName
RS("DocumentName")
RS.Fields("DocumentName")
RS.Fields.item("DocumentName")
RS.Fields.Item("DocumentName").Value

will all give you the same results.

The Fields Object is the default property of the Recordset Object.

The Items object is the default Property of the Fields Object.

Value is the default property of the field object (returned by item).

You could do something like.

Code:
Select case RS("Precint")
  Case "FirstSpecialValue", "SecondSpecialValue", "ThirdSpecialValue"
    ' Put code that formats the data and puts in a word document
  Case Else
    ' Nothing special going on
End Select

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top