Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can a yes/no field display a'check box' using VBA 1

Status
Not open for further replies.

cloverdog

Technical User
Mar 4, 2008
41
0
0
GB
Hello
Could anyone help with changing the ‘display control’ of a yes/no field in a table.
The problem I face is that I have created a table using a query run from a module. One of the field types is a yes/no.

On opening the table the values displayed are 0 or -1. I want it to show a friendlier check box instead. Easily enough done by going into the table design view | selecting the Look Up tab | then setting ‘display Control’ to check box but is there any way of setting this using VBA?

Many thanks
 
Code:
CurrentDb.TableDefs("myTable").Fields("YNField").Properties("DisplayControl") = 106
 
Thanks for the quick reply but it gives an error 'property not found'. I am using MS Access 2003.
 
Put this in the record source of a label

me.Displaycontrol.label = iff ("NameofdisplayControlfield","Yes","No")

Ian Mayor (UK)
Program Error
If people say I have bad breath, then why do they continue to ask me questions and expect me to answer them?
 
sory it should be a textbox control not a label

Ian Mayor (UK)
Program Error
If people say I have bad breath, then why do they continue to ask me questions and expect me to answer them?
 
should in not be

me.Displaycontrol.label = iff (NameofdisplayControlfield,"Yes","No")

without quotes
 
If you are using a form, you can just set the format to Yes/No, but the OP wants a Checkbox.
 
Within the Table design,
Set the Format [True/False|Yes/No|On/Off]
Then Display Control either a Check box [Tick box] or Combo box [Yes/No] will be used on forms.

This detemines which is used on the forms.
 
I would just like to thank you all for your posts. Since this was for use with a temporarary table created immediately before being displayed, setting the property as outlined in Remou's link was the solution. Again many thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top