Third Column Of A DataGrid To Show The Value Of ....
Dear Friends,
I am using MS Access Database. The following are the complete details:
Table: Balance
Fields: 1) Received 2) Sold
DataGrid: dbgBalance
CommandButton: cmdShow_Balance
I have three columns in the DataGrid. First column to show the value of Received field, the Second column to show the value of Sold field and the Third column to show the balance for which there is no field in the table.
So, what I need now is, the Third column should get the value from Received field and deduct the value of Sold from it and then show the resulted value in DataGrid Column Balance.
So, each row in a DataGrid will show the values like this:
1st Row : 5000 2000 =3000 2nd Row : 7000 6000=1000 3rd Row :
. 4th Row :
..
.
And so on
.
How can I do this? Please do help.
Regards,
Margaret
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Programatically &"not Show&" A Datagrid Column?
Hi,
I need to SELECT a column from a table into a datagrid (so that I can clear it if necessary), but don't want to show it. Is there a way to hide a column once it's been retrieved?
Tks,
L.
How To Make Most Right Column Hided Column Show?
Hello, Everyone:
I tried to most right column hided column show. But I can only choose one side: left side. For example, I hide all the columns which is right side of O column. So, I don't how to make all of them show up again? Would someone be kind to help me out?
Thank you very much!
Charlie
Why Won't My Combobox Show The First Column?
Okay, so I have this combo box on a subform that has three columns in it. The first column, which is the bound column, will not display in the drop down list. It's data source is a query that pulls 3 fields from a single table, and all of the fields show up there. Once I choose a record in the combo box, the correct value shows up in the combo box.
Any ideas on what is going on?
Show Column In Listview
I sort a column in a listview, say column 10, by date. the only way I could do this was to reload the listview from a recordset.
I then want to have this column showing, but without reordering the columns.
I have another thread going, here but it seems from the help I have gratefully been given there, that I would need to use Common Controls Version 5, not 6 to do this. Version 6 has a lot more to it, and things that I don't want to give up.
Does anybody know if this is possible to do with version 6?
How To Keep A Column From Show In A MSHFlexGrid?
how to keep a column from show in a MSHFlexGrid?
In my code , I do not want two columns with the same data to show together. How can I hide one?
I tried to set MSHFlexGrid1.colwidth(3)=0,but it caused the left columns can not show properly.
Thank you!
How Do You Show Listbox Column Headers???
Hi everyone, I hope this is simple...
I have a listbox created from a file, which scrolls both vertically and horizontally.
I want to protect my column headers from being deleted, and set column headers to true in the properties, however, nothn happens, I get a blank column at top of listbox. I obviously need to something else here, but what is is it??? I am puzzled!
Show Selected Column (Listview)
I have a listview with approx 20 columns, 4 of which are dates.
When I scroll along to one of these dates columns, and click on the columnheader to sort that column, I clear the listbox and reload in the sort order by recalling the data from the database via a recordset.
The problem is, although the data is sorted as I want, the column that has the sort on it is now not showing. I have to scroll back along to show it.
How can I set it so that the column that has the sort on it is visible?
I looked for an 'EnsureVisible' property, but either I have missed it somehow, or that isn't the way to go.
Listbox Show Selected In Middle Op Column
Hi,
I have a textbox and a listbox.
when i type a string in the textbox,
using sendmessage (list1.hwnd, LB_FINDSTRING,-1, ByVal txtSearcg.text)
The listbox select the fist item that matches the string.
My problem is that I would like that the item selected in the listbox appears in the middle op the listbox.
Example
listbox contains 26 items from "A" to "Z" I type "L" and the following is shown.
(**) means selected.
________
| H |
| I |
| J |
| K |
|**L*** |
|_______|
What I would like to be shown is
________
| J |
| K |
|**L*** |
| M |
| N |
|_______|
does enyone have an solution for me?
Kind regards Piet
How To Show A Formula In The Total Column When Adding Cells?
Hi,
At the moment I have some VB code that adds together specified cells in Excel.
Currently the code is as follows:
.Cells(20, 1) = .Cells(20, 2) + .Cells(20, 3) + .Cells(20, 4)
.Cells(20, 1) totals up the columns ok but how do I display this number as a formula so that if I make changes to columns 2,3 & 4 the number in column 1 will automatically update
Thanks in advance
Why Cannot Show Image Of Vbaccelerator Multi-column Treeview Control ?
Hi all,
I'm using vbaccelerator multi column treeview control. That was run well in loading data but i can't load the image into treeview. I tried in some of the computer it was running well in data loading and picture displaying.
I surf to the net it seem like my computer was missing RC.exe and RCdll.dll. How to install those component ? and it is the cause of my problem ?
Thanks a million :-)
Add Column To Datagrid
Hi everybody; I hope one of you can help me.
I am displaying a table with a datagrid and want to add a column with the values from another table as it's contents.
Both tables have columns titled CODE. The second table has a field called TYPE that corresponds to the CODE (eg. CODE 101 means TYPE Maintenance). What I want to do is put the values of TYPE from the second table into the datagrid displaying the first table I'm not allowed to add a column into the table being displayed by the datagrid.
I'm connecting to the database thru Adodc (DISA for the first table; CODES for the second table)
I found this but when I try to populate the fields from the second Adodc (CODES) it doesn't work. I figure that's because the Datagrid1 is connected to DISA.
Private Sub AddColumn()
Dim c As Column
Set c = DataGrid1.Columns.Add(DataGrid1.Columns.Count)
With c
.Visible = True
.Width = 1000
.Caption = "type"
.DataField = CODES.Recordset.Fields("CODE").Name
'if i use .DataField = DISA.Recordset.Fields("WHATEVER").Name it
'puts the values from 'WHATEVER' into the column "type"
.Alignment = dbgRight
End With
DataGrid1.ReBind
End Sub
Any ideas?? Thanx in advance.
Set DataGrid.Column Value
Hi,
ive got a Problem with my data grid, i have a DataGrid where the Data Source is an DataEnvironment, allright it works, but now i want do add a column to that grid where i calculate fe: Column1 * Column2 but if i want to insert the value in the column with: DG.Columns(3).Value an error apears:
Column not found, |1
what have i to do to do that???
Column In Datagrid
Hi,
I have a datagrid that bind to a table. Some of the columns of the table are not editable. For those columns in the datagrid, I want to gray them out.
The datagrid property does not give enough tools for me to set up.
Please show me how.
Thank you,
Quang
Datagrid Column
On a form I have a datagrid...how do i specify the column width for each seperate column??
Datagrid Column
I don't want my identity column to show up in my datagrid. How do I control which columns I want visible and which ones I don't?
How To Add Column To Datagrid
Anyone know how to manually add a column to a datagrid.
The default value of the grid when you create the object is to only have two columns, I need 13. Thanks
Nightfox02
Datagrid Column Sum
I have a column in datagrid that displays all the prices. I want to sum up all the values from all the rows of that column and display it as a label. How can I sum up the data??
Thanks ... Bhavesh
Add Column To DataGrid
I am new to working with grids and cannot figure out how to add a column.
The grid is a DataGrid ActiveX Contol - Version 6.0. I can look at the
properties and code but cannot see where to add the column.
I appreciate your help.
Kevin
Add A Column In A Datagrid
I would like to know if it is possible to add a column in a datagrid.
I would like to have a column to describe all line in my datagrid.
By the way, is it possible to display a long text in the header on two line but in the same cell.
For example I have the text "this is my new cell"
And I would like that it display like that:
"this is my
new cell"
because I don't want that my columns have a width of 4000
Thanks in advance
How To Add A New Column Into A Datagrid ?
Hi,
I have a datagrid1 on my screen. I have a recordset myRst contains 3 fields (id, name, age). I set myRst as the datasource for my datagrid.
set DataGrid1.datasource = myRst
Then I want to add a new column into this datagrid1, which can show info depend on the value of AGE. for example, if age < 12, show 'KID'; if 13 <= age <= 25, show 'Tenage'....
DataGrid1.Columns.Add (3)
DataGrid1.Columns(3).Width = 350
DataGrid1.Refresh
Now i want to populate this new column using following code:
myRst.movefirst
do while myrst.eof = false
with datagrid1
if .columns(2).value < 12 then
.columns(3).value = "kid"
......
end if
end with
myrst.movenext
loop
When i ran the program, first 3 columns populuated successfully, but last column is empty, and I got following error:
Column not found, /1
What does this mean?
Grace
How To Get The Column Name Of Datagrid
Is there anyone know how to get the number of columns and its corresponding name of datagrid and put it in list box or variable.
Or there's another option except datagrid which get the field name of a table.
Note: I only knew the name of the table but i dont know its field name.
Thank you very much for your reply.
Datagrid Column Sum
I am trying to find a way to sum the values of a column in my datagrid. I have not even found a way to isolate a single cell, row coordinate. Please help.
Datagrid Column Sum
I have a column in datagrid that displays all the prices. I want to sum up all the values from all the rows of that column and display it as a label. How can I sum up the data??
Thanks ... Bhavesh
Datagrid Column Sum
I have a column in datagrid that displays all the prices. I want to sum up all the values from all the rows of that column and display it as a label. How can I sum up the data??
Thanks ... Bhavesh
Datagrid Show Values
Hi peepz, I have a Datagrid which is filled by a recordset.
Now i want to add the value of the row i click on to a textbox, but this isn't done correctly, i have t click twice because the first time i click on a row it's "selected" and the second time it cahanges the value of the textbox.
[vb]
Private Sub Datagrid_Click()
txtField.Text = rstRecordset.Fields(0)
End Sub
[vb]
can anyone tell me a way to do this right ?
Or is it possible to sellect full rows only ?
DataGrid Will Not Show Data
I have a program which used a data enviorment and need to do a custom query against the database. Instead of creating a new connection and everything I just use the one available thru the Data Env. That works but my problem is the datagrid will not display the data. Here is a some of the code
Dim rs As ADODB.Recordset
'dEnvEA.Connection1.Open
Set rs = dEnvEA.Connection1.Execute("SELECT * FROM dbo.ShAgents")
MsgBox rs.RecordCount
MsgBox rs.Fields("AgentID")
Set DataGrid1.DataSource = rs
DataGrid1.Refresh
dEnvEA.Connection1.Close
When the program is run I do see the correct info from the recordcount and the AgentID fields so the recordset is there and filled but I just cant display the data.
Show The Query On A Datagrid
I can show a table of a database file on datagrid control (I have used an ado data control to connect database).
But I have created a query with a long sql command on MS Access.
How can I show that query on a datagrid on my VB project?
Datagrid Does Not Show Any Records
Two parts of question :
VB Code:
private sub Form_Load() call batch_process ' insert data to tblBatch_Load Datagrid1.Refresh end Sub
When batch_process is done,
1) there is no record displayed even using datagrid.Refresh
2) how to print the records from datagrid on the hard copy?
Thanks,
vb999
How To Let Highlighted Row Always Show In The Datagrid?
I have a MSFlexDataGrid, the user may scroll it to bottom, so the first row which is highlighted can not been seen from the screen.
now, the user press the buttom 'add', my program will add one row at the top and highlight the first row (added row). I want the datagrid automatically scroll back so that the first row can be seen from screen. How can I do that?
thanks
DataGrid Not Show Datas
Hi ! I am Hira.
I am learning how to use DataGrid control.
I want to show datas from MS Access table on the DataGrid.
But I could't do that.
Please give me some advices for resolving this problem.
I have confirmed I can connect my VB application with Access DB. My code is as bellow.
Private Sub Form_Load()
Dim MySql As String
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
On Error GoTo Err_Form_Load
cn.ConnectionString = "XXXXXX"
cn.Open
MySql = "SELECT MachineNumber FROM MachineData"
rs.Open MySql, cn, adOpenStatic, adLockOptimistic
Set dbgTrouble.DataSource = rs
Exit_Form_Load:
Exit Sub
Err_Form_Load:
MsgBox (Err.Number & Chr(13) & Err.Description)
End
End Sub
Show Picture In Datagrid
Hello
I have a access database which is linked to vb6 with a adodb control and viewed with a datagrid control. The information shown is as follows:
Log Name
-1 Smith
0 Jones
The log column can only be -1 or 0. So what i would like is in the datagrid, the -1 or 0 to be replaced with a picture. -1 to be one pic and 0 to be another. Is this possible?
Thanx for any help you can provide.
Does DataGrid Show Checkboxes?
I'm new to VB so I'm trying to figure out the best control to use to do the following: A user will find a customer ID and then see a listing of open invoices with some details (date, description, etc.). Then the user can input a Purchase Order (PO) number into a textbox and choose which invoice(s) the PO can apply to. I'd like to have the user be able to mark a checkbox next to the invoice(s) that the PO will apply to. Then Hit OK to save the PO number into the Invoice record. (The database is SQL 7.)
I thought the DataGrid control was the best choice of what comes with VB 6 but I can't figure out how to get a checkbox into the DataGrid.
If I go to the form with the DataGrid, select the DataGrid and right click, and select Properties, I get the Property Pages tab control. I select the Format tab, and then select the column I want to be a checkbox, and then select Checkbox from the list of possible formats. To the right of this choice, the "Help" says "This format allows a checkbox to be set properly when bound to a boolean column." I'm not sure what that means. What I want is to see a checkbox when the data displays.
My datasource is an ADO Data Control which has as its data source a SQL stored procedure. The column that I want to show as a checkbox is of datatype bit.
Can this be done with the DataGrid Control? I would prefer to not have to buy a third party component if it can be done reasonably easily with the DataGrid Control.
Thanks for any help/suggestions you can provide.
Cathy Johnson
Oakland, CA
How Can I Show The Selected Row In Datagrid
hello
i want to show current row which is the result of my query in datagrid
how can i do ?
In MSDN it is written "The data in the current row can be accessed using the Bookmark property"
ok it works but i want to set datagrid like datagrid1.bookmark =i but it doesn't work
also datagrid1.row is not the property that i want to use .
Three Options To Show In Datagrid, How?
Hi I have a table Parts, a table PartUsage and a UI that allows the user to pick a Part, a Part Category, or all Parts and show the resulting PartUsages in a DataGrid. The all Parts works fine using SqlDataAdapters for the tables and a relationship in the schema. I change the Parts adapter selection to add a parameter for either a Part or Category. I have set up relations for the other choices. When I try to use the Part Category or a single Part I come to grief with exceptions for arguments. I am supplying a value for the parameter.
[code] For Example:
DataSet11.Clear()
daParts.SelectCommand.CommandText = "Select * From Parts Where PartID = @partid"
daParts.SelectCommand.Parameters.Clear()
daParts.SelectCommand.Parameters.Add("@partid", SqlDbType.Int)
daParts.SelectCommand.Parameters("@partid").Value = intPartID
daParts.Fill(DataSet11)
[/code]
But when I try to do the same with the PartUsage table I get a error
Code:daSelectPart.SelectCommand.Parameters.Clear()
daSelectPart.SelectCommand.Parameters.Add("@partid", SqlDbType.Int)
daSelectPart.SelectCommand.Parameters("@partid").Value = gblintPartID
daSelectPart.Fill(DataSet11)
DataGrid1.DataSource = DataSet11
DataGrid1.DataMember = "PartsSelectPartUsage"
An unhandled exception of type 'System.ArgumentException' occurred in system.windows.forms.dll
Additional information: Cannot create a child list for field PartsSelectCategoryUsage.
What am I doing wrong? Am I doing anything right? TIA
Datagrid Does Not Show All Records
Hi,
My first time to ask here. I got a VB6 program that shows records in a datagrid "dtg". The datasource property of dtg is an adodc object named "adg".
Here's the code.
Code:
Private Sub Form_Load()
Dim strSQL As String
Dim i As Integer
strSQL = "Select * From table"
adc.ConnectionString = TempDB.ConnectionString
adc.RecordSource = strSQL
adcPR.Refresh
end sub
The problem is it does not show all records in the datagrid. Will I set a delay for an event?
Thanks in advance
DataGrid Column Width Value?
In this expression...
DataGrid.Columns.Item(iCol).Width = 1000
What type is '1000'?
Is it a Pixel, char...number.....etc....i cant figure it out......
the reason for this is I have a MSflex grid which has a column width of 20...i would like to know how to convert that number to the equiv in a datagrid..Please any help would be great. Thanks in advance
Datagrid Column Control
I want to remove the column in my datagrid that shows the ID. How do you control which columns are visible?
Datagrid Column Width ????
I have two datagrids that are exactly the same. The only difference is that I am using them on different forms, and one of them has a filter.
My question is this.
On the first datagrid, I could write column widths like this
AppointmentsDataGrid.Columns("time").Width = 40
AppointmentsDataGrid.Columns("patient").Width = 150
AppointmentsDataGrid.Columns("Doctor").Width = 150
AppointmentsDataGrid.Columns("status").Width = 50
and the output was as I expected.
but then, on the second grid, when I write the same thing, the column widths get rediculously small. Is there a way of specifying the units used for the column widths that I have missed?
Jagdip
DataGrid - Format Of One Column
Set grdStock.DataSource = Adodc1
grdStock.Refresh
grdStock.Columns(0).Width = 900
grdStock.Columns(1).Width = 1700
grdStock.Columns(2).Width = 1700
grdStock.Columns(3).Width = 1700
grdStock.Columns(4).Width = 1700
rdStock.Columns(4).DataFormat = FormatCurrency(Price)
So I want to make column(4) with Format Currency. I tried this but does not work. Does anybody have idea how I can make this format in DataGrid?
Thanks,
Ilimax
Datagrid Column Question
I have a datagrid and would like all the cells in the first column to be "RECEIVE".
I've tried
DataGrid1.columns(0).text = "RECEIVE"
AND
DataGrid1.columns(0).value = "RECEIVE"
Neither worked
I was reading something about the DefaultValue property in my vb book that seems would work for my problem but ofcourse it has no examples. I also looked it up on the MSDN and it talks about using a Tag property, which I dont know how to use.
Datagrid Column Widths
I am using a datgrid, and looking for a way to "autosize" the column widths. Is this possible, or do I need to know the lenth of my data in order to set the column width?
Thanks
How To Set Datagrid Column To Uneditable
Hi. I have a form contains a datagrid (with 2 fields/columns: ID, UserName) and two command buttons ("Add", "View All"). When user clicks on "View All" button, the datagrid will display all the user information (ID 1 to 10) with the "ID" column/field is NOT editable. When the user clicks on the "Add" button, a new row (ID = 11) will be APPENDED as the last row in the current datagrid. In this case, user can add or modify this NEW appended Row (which mean ONLY the row with ID =11 is set to editable) while ID =1 to 10 is NOT editable also. I have use the following methods to make the new row(ID = 11) to editable but to no avail.
Any suggestion is truly appreciated.
Code:
'at form load
datagrid.column(0).locked = true
'when user clicks Add button
datagrid.CurrentCellModified = True
datagrid.EditActive = True
|