Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Datagrid Control

Posted on 2006-07-06
6
Medium Priority
?
241 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 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

926 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