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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display a Checkbox value in a datagrid 1

Status
Not open for further replies.

bubarooni

Technical User
Joined
May 13, 2001
Messages
506
Location
US
I am using Access 2000 as the database. When I load the checkbox value in the datagrid it displays as '0' or '1'. I would like it to display as 'Yes' or 'No'.

I am sure there is a way...

Thanks
 
Just trying to keep it at the top of the list where someone with an answer might see it.

I haven't been able to find anything on it. My Google searching abilities seem a bit inadequate on this one.

 
If you are using a flexgrid and loading from a recordset you could use,
flexgrid1.additems IIF(rs1!value = 1, "Yes", "No")

or something to that effect

not sure if it is bound grid
 
bubarooni...

1 = yes, 0 = no

like true and false

You could use a text field instead and write your code to write a "Yes" or a "No" to the table.field.

Is this an Access application or is it a VB application with an Access database as the backend?



[fish] No Dolphins were harmed in the posting of this message... Dolphin Friendly Tuna!
 

DataGrid1.Columns("SomeField").NumberFormat = "Yes/No"
 
It is a VB application with an Access back end. The datagrid is 'unbound' in that I am creating an ado recordset programmatically from a sql select statement and then dumping the entire results into the datagrid.

I am not sure how to implement it but, I'll tinker around and see if CCLINT's suggestion can fix me up when I get back to the office. I think I am just setting the recordsource of the datagrid to the ado recordset.

I am out of town working at one of our remote locations today (Cisco router problems) but will post the code I am using tomorrow if I can't get any of the suggestions to work.

Thanks
 
OK, I am a fool.

I jacked around with the Format property of the datagrid column in question and got it to display correctly.

Thanks for keeping hope alive in the meantime though. I was ready to give up till you guys got me nosing around again.

Now, if only the datagrid allowed me to highlight a row where the value was set to 'Yes' I'd have it made. I think only a flexgrid will do that though.

Thanks again.
 
Bubarooni, you mentioned in this thread that you were able to fool around with the formatting to show an actual checkbox for a boolan field? I have the exact same issue where I want tthat as well. Can you let me know what you did with formatting to get it to work?

Much appreciated!!!!

 
OK, here is what I did:

1. Right click the DataGrid in question.
2. From the pop-up menu, select 'Properties'.
3. From the 'Property Pages' box, select the tab 'Format'.
4. In the 'Format Item' drop down, select the column you wish to format.
5. In 'Format Type', select Boolean.
6. For 'True Value', type 'Yes'.
7. For 'False Value', type 'No'.

I left the 'Null Value' blank because this field in my DB, Inactive_Physicians, is formatted to 'Yes/No' and I believe defaults to 'No'. Double check your DB field to see how it is formatted in case the blank value for NULL throw's an error in your code.

Anyway, that's from memory so if it doesn't work for you let me know and I'll go back thru the actual project.

Bubarooni
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top