[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Setting the Display Control property of a table field to Check Box

Posted on 2006-05-24
9
Medium Priority
?
433 Views
Last Modified: 2010-05-18
The following code is my attempt to set the Display Control property = "Check Box" for a table field named MyCheckBox which I am adding to the table trefLinkList. I get the error Data Type Mismatch on the line that is supposed to set the DisplayControl property:

 Set prp = tdf.Fields("MyCheckbox").CreateProperty("DisplayControl", dbInteger, acCheckBox)


'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim db As Database
Dim tdf As TableDef, tf As Field
Dim prp As Property
 
 Set db = CurrentDb
 Set tdf = db.TableDefs("trefLinkList")
 
 With tdf
  .Fields.Append .CreateField("MyCheckbox", dbBoolean)
 End With
 
 tdf.Fields.Refresh
 Set tdf = db.TableDefs("trefLinkList")
 Set prp = tdf.Fields("MyCheckbox").CreateProperty("DisplayControl", dbInteger, acCheckBox)
 tdf.Fields(tf.Name).Properties.Append prp
0
Comment
Question by:paulmcneil
7 Comments
 
LVL 61

Accepted Solution

by:
mbizup earned 1000 total points
ID: 16754812
You haven't defined tf, which you are using in the following line:
>tdf.Fields(tf.Name).Properties.Append prp

Your code works beatifully in Access 2003, by changing this line to:
tdf.Fields("MyCheckbox").Properties.Append prp


0
 

Author Comment

by:paulmcneil
ID: 16754920
mbizup,
I took your advice and now I get the data type mismatch on

Set prp = tdf.Fields("MyCheckbox").CreateProperty("DisplayControl", dbInteger, acCheckBox)
0
 
LVL 61

Expert Comment

by:mbizup
ID: 16754968
What version of access are you using?
0
Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

 
LVL 34

Expert Comment

by:jefftwilley
ID: 16763013
Can you use this?
 
        strSQL = "Alter Table tbl_Specs ADD COLUMN ["ColumnName"] YesNo"
        CurrentDb.Execute strSQL
0
 

Author Comment

by:paulmcneil
ID: 16763247
I'm using Access 2003 SP2
0
 
LVL 61

Expert Comment

by:mbizup
ID: 16768311
Paul,

Thats the same version I'm using.  When something works on one machine but not another, the first thing I check is references (although I'd expect a different error message if it were a reference problem).  Anyhow to rule that out as a possibility, open a VBA module and go to Tools -> References.  Do you see anything flagged as MISSING?
0
 
LVL 58

Assisted Solution

by:harfang
harfang earned 1000 total points
ID: 16770669
Hello paulmcneil

Both ADODB and DAO have an object type called "Property". If your "ActiveX Data Objects" is loaded first in the list of references (it probably is), you would get a type mismatch. You need to be explicit:

    Dim prp As DAO.Property

Your code will work fine with that change.
Gool luck!
(°v°)
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

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, …
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

830 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