Solved

Datagrid Control

Posted on 2006-07-06
6
232 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
  • 3
  • 3
6 Comments
 
LVL 69

Accepted Solution

by:
Éric Moreau earned 125 total points
Comment Utility
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
Comment Utility
Guess I spoke too soon.

How exactly do you implement this code ?
0
 
LVL 69

Expert Comment

by:Éric Moreau
Comment Utility
Just after you gave the recordset to the grid, you paste the first block of text. What is the code you currently have?
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

Author Comment

by:ittechie100
Comment Utility
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 69

Expert Comment

by:Éric Moreau
Comment Utility
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
Comment Utility
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now