Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / May 2005

Tip: Looking for answers? Try searching our database.

DisplayControl property on a field using DAO in C#

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
L Magarian - 03 May 2005 01:12 GMT
Hello,

I am trying to set the DisplayControl property on a field using DAOin
C#.  I've found lots of sample code for VB and am trying to adapt it
for use in C#.

This is the code I'm running now:

DAO.Field f = db.TableDefs[TableName].Fields­[ColumnName];

//110 is list box
DAO.Property p1 = f.CreateProperty("DisplayContr­ol", Type.Missing ,
110, Type.Missing);
f.Properties.Append( p1 );

This is the error:

[COMException (0x800a0d3a): Property 'Value' must be set before using
this method.]  DAO.Properties.Append(Object Object) +0

The third parameter in the CreateProperty method is the value, so I
don't know why it's not being set.

Any help figuring this out would be greatly appreciated.
Paul Overway - 03 May 2005 01:29 GMT
You're not likely to get much help with C# in this forum....VBA?  Yes.

Even though the error says Value, I'd suspect the Type parameter.  Try
passing a 3 for the Type parameter.

Signature

Paul Overway
Logico Solutions
http://www.logico-solutions.com

> Hello,
>
[quoted text clipped - 20 lines]
>
> Any help figuring this out would be greatly appreciated.
L Magarian - 03 May 2005 17:23 GMT
Thanks for the tip.  Unfortunately, using 3 for the type causes another
runtime exception:
[COMException (0x800a0d5d): Data type conversion error.]
  DAO.FieldClass.CreateProperty(Object Name, Object Type, Object Value,
Object DDL) +0

I tried a few other values including
System.Type.GetType("System.Int32")
System.Type.GetTypeCode(System.Type.GetType("System.Int32"))

This is the line of code:
DAO.Property p1 = f.CreateProperty("DisplayControl",
System.Type.GetTypeCode(System.Type.GetType("System.Int32")) , 110,
Type.Missing);
f.Properties.Append( p1 );

Does anyone know what this parameter is expecting to recieve or have
recomendations about where to look to find info on this question?

Thanks!

> You're not likely to get much help with C# in this forum....VBA?  Yes.
>
[quoted text clipped - 25 lines]
> >
> > Any help figuring this out would be greatly appreciated.
Mark Burns - 03 May 2005 21:31 GMT
The problem appears to be with the CreateProperty call.
A few key points from The Access 2002 help for this read:
(Comments inline below denoted thus: <*** my stuff ***>)
<quote>
CreateProperty Method

Creates a new user-defined Property object (Microsoft Jet workspaces only).

Syntax

Set property = object.CreateProperty (name, type, value, DDL)

The CreateProperty method syntax has these parts.

Part Description
name Optional. A Variant (String subtype) that uniquely names the new
Property object.

type Optional. A constant that defines the data type of the new Property
object. See the Type property for valid data types.
<*** this will need to be a type as defined in the DAO .DLL, a DataTypeEnum
- not a .net system.(whatever) framework type ***>

value Optional. A Variant containing the initial property value. See the
Value property for details.

DDL Optional. A Variant (Boolean subtype) that indicates whether or not the
Property is a DDL object. The default is False. If DDL is True, users can't
change or delete this Property object unless they have dbSecWriteDef
permission.
<*** Shouldn't you be setting this TRUE for your purposes here? ***>

Remarks
<snip>
Note If you omit the DDL argument, it defaults to False (non-DDL). Because
no corresponding DDL property is exposed, you must delete and re-create a
Property object you want to change from DDL to non-DDL.
</quote>
L Magarian - 03 May 2005 23:38 GMT
Thank you so much!  That was exactly the information I needed.

> The problem appears to be with the CreateProperty call.
> A few key points from The Access 2002 help for this read:
[quoted text clipped - 34 lines]
> Property object you want to change from DDL to non-DDL.
> </quote>
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.