?
Solved

Determining control field type (from the form control)

Posted on 2016-11-30
4
Medium Priority
?
33 Views
Last Modified: 2016-11-30
Is there a fast/clean way of determining the field type (directly from the form)?  I have a function that creates a shortcut menu when a control gets focus (pretty much every field/control on the form will do this).  

Some of the options on this shortcut are in relation to filtering, and I want to be able to determine the actual field type (not the value within the field).  I know that I can pole the table directly with something like this (ctl.name is the field that has focus).

currentdb.TableDefs("_tblMain").Fields(ctl.name).type

However, if there is a better way without looking at the table directly, I think it might be more efficient.
0
Comment
Question by:Andy Brown
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 85

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 2000 total points
ID: 41907067
I don't think the Form itself has any knowledge of the Datatype of the fields bound to controls. Your method should work fine, but unless you're using the Field name as the Control name (which is a bad idea), then you would need something like this:

CurrentDb.TableDefs("Table1").Fields(Me.Worked_Department.ControlSource).Type

The highlighted portion would be changed for each control.
0
 

Author Closing Comment

by:Andy Brown
ID: 41907082
Yep - I just spotted that one :O)

Thanks for the help.
0
 
LVL 58
ID: 41907086
A better option, although less automatic, would be to use the controls tag property.  

 This would give you more granular control over what controls allow for filtering, and the type of filtering that should be used.

Jim.
0
 

Author Comment

by:Andy Brown
ID: 41907091
Thanks Jim (as always).  I'll take a look.
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Suggested Courses

762 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