Solved

Datagrid Control

Posted on 2006-07-06
6
237 Views
Last Modified: 2013-12-25
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
 
0
Comment
Question by:ittechie100
[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
  • 3
  • 3
6 Comments
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 125 total points
ID: 17052149
Hi ittechie100,

You cannot have a checkbox column to the DataGrid but you can and a Yes/No column this way (you have to set a reference to Microsoft Data Formatting Object Library):

Dim fmtBooleanData As StdDataFormat
With grdImport
   .Columns(0).Locked = True
   ' 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
End With

To change its value, you can use:
Private Sub grdImport_DblClick()
    grdImport.Columns(0).Value = Not grdImport.Columns(0).Value
End Sub

Cheers!
0
 

Author Comment

by:ittechie100
ID: 17062056
Guess I spoke too soon.

How exactly do you implement this code ?
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 17064788
Just after you gave the recordset to the grid, you paste the first block of text. What is the code you currently have?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:ittechie100
ID: 17080988
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
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 17081007
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
0
 

Author Comment

by:ittechie100
ID: 17081019
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.

0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

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