Link to home
Start Free TrialLog in
Avatar of ittechie100
ittechie100

asked on

Datagrid Control

Using VS6 SP5, Have a datagrid in my application that is retrieving data from my Access database.

Works great, except for one thing, when it pulls a value from the database that was a Checkbox control
it only displays -1 or 0 in the columns of the datagrid. Is there a way to convert it to reflect "Yes or No" ?

There is a total of four checkboxes to choose from, The user only needs to check one box in the APP, however all of the
fields in the datagrid come back with 0's and -1's in them. Can I stop the data from pulling if it was an unchecked value to begin with ?

Thanks
 
ASKER CERTIFIED SOLUTION
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ittechie100
ittechie100

ASKER

Guess I spoke too soon.

How exactly do you implement this code ?
Just after you gave the recordset to the grid, you paste the first block of text. What is the code you currently have?
This is my current code for this module:
When my managers click on ViewPTO Request it populates any open PTO Request, and I need the checkbox
columns to display in something other than -1 or 0 for easier reading....
       
         Case "ViewPTORequest"
         DataGrid3.Visible = True
         DataGrid2.Visible = False
        'DataGrid4.Visible = False
        'DataGrid5.Visible = False
        WebBrowser1.Visible = False
        WebBrowser2.Visible = False
        'With Adodc3
        Adodc3.CommandType = adCmdUnknown
        strSQL = "SELECT PTOID, EmployeeName, RoutineRequest, EmergencyRequest, PTOStatus  FROM PTORequest WHERE PTOStatus Like 'TRN%'"
        Adodc3.RecordSource = strSQL
        Adodc3.Refresh
        Adodc3.Recordset.Sort = "PTOID ASC"
        DataGrid3.ReBind
have you tried this:

       DataGrid3.ReBind  'Your current last line

Dim fmtBooleanData As StdDataFormat
With DataGrid3
   .Columns(0).Locked = True   'TODO Replace the 0 with the column number in which you have a boolean value
   ' set up Boolean Formatting
   Set fmtBooleanData = New StdDataFormat
   fmtBooleanData.Type = fmtBoolean
   fmtBooleanData.TrueValue = "Yes"
   fmtBooleanData.FalseValue = "No"
   fmtBooleanData.NullValue = "No"
   Set .Columns(0).DataFormat = fmtBooleanData     'TODO Replace the 0 with the column number in which you have a boolean value
End With
Thanks for the assistance, but it was alot easier to just select properties of the datagrid and
change to boolean, Yes/No

I do appreciate the help in the right direction.