Hybrid Access 2010/Sharepoint 2010 app web form - variable to pass fieldname to Where Condition in BrowseTo Action?

Is it possible to use a variable to pass a fieldname in the Where condition of a BrowseTo action in an Access 2010/Sharepoint 2010 hybrid web form? I have a form where

Where condition= [fieldname] Like "*text value*"

filters the records correctly, but if I set a temp variable to "[fieldname]" and use

Where condition=[TempVars]![fieldname] Like "*text value*"

no records are returned. Is there a syntax that will allow me to use a variable in place of the actual fieldname? I'm filtering the recordset based on a combo box selection plus a text field entry. If I can use a variable instead of the native fieldname it will save me a whole bunch of If statements in the macro.
Who is Participating?
dgmoore1Author Commented:
I decided to just use a bunch of If.. statements. It makes the macro a bit long and convoluted, but it gets the job done. I would still like to find a way to pass the fieldname in a variable - it would make things cleaner.
Jim Dettman (Microsoft MVP/ EE MVE)President / OwnerCommented:

  Don't know specifically, but normally you can't use a variable directly like that unless it's in code.  What you can try is defining a function to return the value and call the function. ie.

Public Function GetTempVar()

   GetTempVar = <variable>

End Function

 And for the WHERE:

  Where condition = GetTempVar() Like "*text value*"

dgmoore1Author Commented:
Unfortunately, code can't be used in Sharepoint Access Services web forms - all actions have to be encoded in macros.
Jim Dettman (Microsoft MVP/ EE MVE)President / OwnerCommented:

That's right, you can't use vba in a web only db. Sorry.
dgmoore1Author Commented:
Not sure if using multiple If statements is the optimal solution here, but it works.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.