?
Solved

checkbox column Access VBA

Posted on 2014-04-21
12
Medium Priority
?
1,528 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

752 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