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

Help with syntax

Status
Not open for further replies.

SteveCarrier

Programmer
Aug 6, 2002
34
CA
Hello, I was wondering if this syntax is correct cause I am having some problems with it.

strValue = Form_frmTest.[strFieldName]

I need strValue to equal the value of the field contained in the variable strFieldName.

For example strFieldName might contain pgCategoryName and therefore I need access to find:

strValue = Form_frmTest.pgCategoryName

With the syntax above I get a "Microsoft cannot find the field "|" as found in your expression" error.

Thanks in advance.

Steve Carrier
 
Thanks everyone I got what I needed in my other post! Thanks!
 
HI,

Dim strValue As String, strFieldName As String

strFieldName = "pgCategoryName"

'If strFieldname is referring to a control on your form then use this:
strValue = Me.Controls(strFieldName)

'if strFieldName is referring to a field in the recordsource of the form.
strValue = Me.Recordset.Fields(strFieldName)

Have a good one!
BK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top