Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Datagrid Control

Posted on 2006-07-06
6
Medium Priority
?
240 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 500 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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 process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

715 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