Solved

Determining control field type (from the form control)

Posted on 2016-11-30
4
11 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
  • 2
4 Comments
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 500 total points
Comment Utility
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
Comment Utility
Yep - I just spotted that one :O)

Thanks for the help.
0
 
LVL 57

Expert Comment

by:Jim Dettman (Microsoft MVP/ EE MVE)
Comment Utility
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
Comment Utility
Thanks Jim (as always).  I'll take a look.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

771 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

7 Experts available now in Live!

Get 1:1 Help Now