?
Solved

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

Posted on 2011-05-04
5
Medium Priority
?
609 Views
Last Modified: 2012-05-11
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.
0
Comment
Question by:dgmoore1
  • 3
  • 2
5 Comments
 
LVL 58
ID: 35690769

  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*"

JimD.
0
 

Author Comment

by:dgmoore1
ID: 35691135
Unfortunately, code can't be used in Sharepoint Access Services web forms - all actions have to be encoded in macros.
0
 
LVL 58
ID: 35691689

That's right, you can't use vba in a web only db. Sorry.
0
 

Accepted Solution

by:
dgmoore1 earned 0 total points
ID: 35691956
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.
0
 

Author Closing Comment

by:dgmoore1
ID: 35763159
Not sure if using multiple If statements is the optimal solution here, but it works.
0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
Sometimes MS breaks things just for fun... In Access 2003, only the maximum allowable SQL string length could cause problems as you built a recordset. Now, when using string data in a WHERE clause, the 'identifier' maximum is 128 characters. So, …
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question