Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

checkbox column Access VBA

Posted on 2014-04-21
12
Medium Priority
?
1,549 Views
Last Modified: 2014-04-21
Hello,

I am trying to add a new checkbox column in tblBox.

The new column name should be “myC”
I am trying to use vba and ddl but no success so far…can someone help?

Thank you
0
Comment
Question by:Rayne
[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
12 Comments
 
LVL 10

Expert Comment

by:Anthony Berenguel
ID: 40013608
Can you provide what code you have so far so we can see what you're doing?

Thanks!
ab
0
 

Author Comment

by:Rayne
ID: 40013612
CurrentDb.TableDefs("tblPass").Fields("BoolField").DisplayControl = acCheckBox

doesnt work
0
 

Author Comment

by:Rayne
ID: 40013626
And I need to appear as real checkboxes, not as zeros as they are now…
0
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 

Author Comment

by:Rayne
ID: 40013638
Dim db As DAO.Database
    Set db = CurrentDb

    Dim tdf As DAO.TableDef
    Dim fld As DAO.Field

    Set tdf = db.TableDefs("tblpass")
    Set fld = tdf.CreateField(colName, dbBoolean)
    tdf.Fields.Append fld

    fld.Properties.Append fld.CreateProperty(colName, dbInteger, CInt(acCheckBox))

    db.Close
    Set db = Nothing
0
 

Author Comment

by:Rayne
ID: 40013640
is adding a new column but that column is not appearing as checkbox...
0
 
LVL 85
ID: 40013742
What do you mean it doesn't appear as checkbox? Do you mean when you view the table, or when you drag into onto a form?
0
 
LVL 46

Accepted Solution

by:
aikimark earned 2000 total points
ID: 40013771
I've encountered similar problems trying to supply certain attributes and properties at the time I created an object, such as a field.  I think this is another example of the same software quirk.

I think you'll have to do that in three statement -- create both the field and the property and then append the property.  Your code comes very close.
Example:
    Dim db As DAO.Database
    Set db = CurrentDb

    Dim tdf As DAO.TableDef
    Dim fld As DAO.Field
    Dim propThing As Property    'new

    Set fld = tdf.CreateField(colName, dbBoolean)
    tdf.Fields.Append fld

    Set propThing = fld.CreateProperty("DisplayControl", dbInteger, acCheckBox)

    fld.Properties.Append propThing

    db.Close
    Set db = Nothing

Open in new window

0
 

Author Comment

by:Rayne
ID: 40013912
that's perfection Aikimark,

that's perfection, thank you, you saved the day :)
0
 

Author Comment

by:Rayne
ID: 40013917
Hello Aikimark,

I really liked your approach,

here is anther one if you are interested :)
http://www.experts-exchange.com/Database/MS_Access/Q_28417181.html
0
 

Author Comment

by:Rayne
ID: 40013927
also AikiMark,

what do you mean here programmatically by saying append ?
0
 
LVL 46

Expert Comment

by:aikimark
ID: 40013936
what do you mean here programmatically by saying append ?
You actually use an Append method for both the field object (to the tabledef's fields collection) and the property (to the field's properties collection).

Your solution is in code, rather than a manual process.  That is why I might use a "programmatic" descriptor.
0
 

Author Comment

by:Rayne
ID: 40014006
great, nice explanation Sire
 thank you :)
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

Outlook for dependable use in a very small business   This article is about using the Outlook application (part of Microsoft Office) in a very small business, or for homeowners where dependability and reliability are critical requirements. This …
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

604 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