473,387 Members | 1,517 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Boolean Field Properties.

Okay here is my problem. I have a table that is imported by the user and
then I need to add a boolean field to the table with Format Yes/No and the
Display Control as Check box. Here is what I have.
------------------------------------------------------------
Dim DB As DAO.Database, MyTableDef As TableDef
Dim MyField As Field

Set DB = CurrentDb()
Set MyTableDef = DB("Client Copy")
Set MyField = MyTableDef.CreateField("Selection", dbBoolean)

MyTableDef.Fields.Append MyField
------------------------------------------------------------
Any help is very much appriciated.

-Andrew

--
Message posted via http://www.accessmonster.com
Nov 13 '05 #1
1 5498
Try:
MyField.CreateProperty("DisplayControl", dbInteger, CInt(acCheckBox))

The routine below is what I use to set the property if it already exists, or
create and set the property if it doesn't. For this example, you would call
it like this:
Call SetPropertyDAO(MyField, "DisplayControl", dbInteger,
CInt(acCheckBox))

----------------------code starts----------------
Public Function SetPropertyDAO(obj As Object, strPropertyName As String, _
intType As Integer, varValue As Variant, Optional strErrMsg As String) As
Boolean
On Error GoTo ErrHandler
'Purpose: Set a property for an object, creating if necessary.
'Arguments: obj = the object whose property should be set.
' strPropertyName = the name of the property to set.
' intType = the type of property (needed for creating)
' varValue = the value to set this property to.
' strErrMsg = string to append any error message to.

If HasProperty(obj, strPropertyName) Then
obj.Properties(strPropertyName) = varValue
Else
obj.Properties.Append obj.CreateProperty(strPropertyName, intType,
varValue)
End If
SetPropertyDAO = True

ExitHandler:
Exit Function

ErrHandler:
strErrMsg = strErrMsg & obj.Name & "." & strPropertyName & _
" not set to " & varValue & ". Error " & Err.Number & " - " &
Err.Description & vbCrLf
Resume ExitHandler
End Function

Public Function HasProperty(obj As Object, strPropName As String) As Boolean
'Purpose: Return true if the object has the property.
Dim varDummy As Variant

On Error Resume Next
varDummy = obj.Properties(strPropName)
HasProperty = (Err.Number = 0)
End Function
---------------------code ends--------------------

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Andrew Smith via AccessMonster.com" <fo***@nospam.AccessMonster.com> wrote
in message
news:79******************************@AccessMonste r.com...
Okay here is my problem. I have a table that is imported by the user and
then I need to add a boolean field to the table with Format Yes/No and the
Display Control as Check box. Here is what I have.
------------------------------------------------------------
Dim DB As DAO.Database, MyTableDef As TableDef
Dim MyField As Field

Set DB = CurrentDb()
Set MyTableDef = DB("Client Copy")
Set MyField = MyTableDef.CreateField("Selection", dbBoolean)

MyTableDef.Fields.Append MyField
------------------------------------------------------------
Any help is very much appriciated.

-Andrew

Nov 13 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Alex Moskalyuk | last post by:
In the GUI application I am writing I have some checkboxes for various settings. The code right now has internal boolean variables and the events that are fired off on checkBox_CheckedChanged for...
38
by: news.microsoft.com | last post by:
Greetings, I am posting this message to both the SQL Server and C# news groups because this inquiry is more of a theoretical question that applies to both database and code naming conventions. ...
3
by: Daves | last post by:
trying to get a boolean value from DataReader (that is, result from a SQL query); boolean MyBool = MyDataReader.GetBoolean(3); well it works using that number 3 but of course I would like to...
7
by: Donald Grove | last post by:
Is it possible to retrieve field properties from a table in access2000 using code? I have tried: " dim dbs as dao.database dim tbl as dao.tabledef dim fld as dao.field dim prop as...
1
by: Tom | last post by:
Hi there I have a little problem here, wich i think is quite strange... I have a dataset, filled from my SQL database. In it are some boolean fields (or bit as SQL server calls them) Now, on...
10
by: Henri | last post by:
In java for instance there's a way to use booleans as objects and not as value types. I would like to do the same in VB.NET so that I can check if the boolean has been explicitely defined (is not...
17
by: The Frog | last post by:
Hello everyone, I am working on an application that can build database objects in MS Access from text files. I suppose you could call it a backup and restore type routine. Accessing the...
4
by: Yitzak | last post by:
Have a query that is arregated into crosstab query, it is working correctly. select Yes as selected from tblname or select true as selected from tblname Produces -1 ( vba value of True) in...
19
by: tshad | last post by:
I have a value in my sql table set to tinyint (can't set to bit). I am trying to move it into a boolean field in my program and have tried: isTrue = (int)dbReader and isTrue =...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.