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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Referencing a field

Status
Not open for further replies.

JasonHampson

Technical User
Feb 20, 2003
16
GB
I’m sure the answer for this is really simple. I've got a table which holds the paths to standard letters. The code I’ve produced already opens the file, uses text stream to get the contents. The texts are in the form “text <<reference to a field>> text”
e.g.
Dear <<Contact Name>>,
Thank you…

Where ‘contact name’ is the name of a field I wan to get information from. I can find the part between the angle brackets (by using section = Mid(letterText, startPos + 2, endPos - (startPos + 2)) ) and store it in a variable but how do I reference the field I’ve tried:
queryRecord!secton
queryRecord!(section)
queryRecord![section]

where queryRecord is a recordset

I think the first and third example is trying to find a field called section and the middle example gives an error message “Type-declaration character does not match declared data type” any ideas??

Cheers
 
I just put up a post but I think I may have made it too complicated. I want to access information in a field in a table. I have a recordset and I know I can get its value by using the form recordset!field e.g myRecord!Name for the ‘name’ attribute. I was just wondering how you referenced it when the field name is in a variable because I was having problems getting it working.
 
you should be able to use this:

MyForm.Controls(FieldName)
 
Try removing the &quot;!&quot; and enclosing the Variable in Round Brackets:

RecordSetName(VariableName).Value

or

RecordSetName(VariableName).Name
 
Yeah sorry I realized that I shouldn't have the '!' when using the round brackets, cheers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top