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

Posted on 2011-05-04
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.
Question by:dgmoore1
    LVL 56

    Expert Comment

    by:Jim Dettman (Microsoft MVP/ EE MVE)

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


    Author Comment

    Unfortunately, code can't be used in Sharepoint Access Services web forms - all actions have to be encoded in macros.
    LVL 56

    Expert Comment

    by:Jim Dettman (Microsoft MVP/ EE MVE)

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

    Accepted Solution

    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.

    Author Closing Comment

    Not sure if using multiple If statements is the optimal solution here, but it works.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Suggested Solutions

    Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
    I thought I'd write this up for anyone who has a request to create an anonymous whistle-blower-type submission form created using SharePoint 2010 (this would probably work the same for 2013). It's not 100% fool-proof but it's as close as you can get…
    Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
    In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

    755 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

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now