How To Pick Value From A Specific Cell In DataGrid
hi dears
how can i pick value of a specific cell from a datagrid.
thanx in adavance
tariq
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Value Of Specific Cell In DataGrid
Hi!
i am displaying data in a DataGrid. In Click()event i want to get the column(0).value, column(1).value and column(3).value in to variables , of that row. Then i have to open a recordset, these 3 variables as parameters.
Code:Private Sub grdDataGrid_Click()
Dim sCurAccType$, sCurTaxType$, sStatus$
Set rsShowDetails = New ADODB.Recordset
sCurAccType = grdDataGrid.Columns(0).Text 'Account_Type
sCurTaxType = grdDataGrid.Columns(1).Text 'Tax_Type
sStatus = grdDataGrid.Columns(3).Text 'Status
rsShowDetails.Open ("SELECT * FROM tbl_TransDetails WHERE Account_Type = '" & sCurAccType & "'" _
& " AND Tax_Type= '" & sCurTaxType & "'" _
& " AND Status = '" & sStatus & "'" _
& " AND Entry_Date = #" & cmbEntryDate.text & " # " )
Me.Hide
Show frmShowDetails
End Sub
I tried with the above code. It is getting values, but with the first row of data. but i want to get values of the row i clicked. Please help me.
Thanks!
>>>>>>>>>>>>>>
Edited by - sreddy on 3/22/2005 8:04:45 AM
How To Set Focus To Specific Cell In A Datagrid?
Hello brainy people,
I love this place because there are so many brainier people than me here. I can usually find answers to my insignificant little problems with a simple search. But this time I need to post.
I have a datagrid (datagrid1) on my form which is linked to an ADO recordset (rsProductCosts). To validate the data entered by the client I use the sub Datagrid1_Validate to loop through the recordset and check that each required column has been completed and it's contents confirm to the required datatype. The point at which I am having a problem is passing focus back to the relevant cell of datagrid1 when the data doesn't pass validation. The validate method automatically returns focus to the datagrid but not to the cell which requires action by the client. I have tried the following;
rsProductCosts.AbsolutePosition = currentrow
DataGrid1.col = currentcol
but I can't seem to get it to work. Is it even possible.
Regards
JohnFromPerth
Accessing A Specific Cell In A DataGrid?
Hi,
I have a datagrid hooked up to a MySQL database. I was wondering how I can access a specific row, column, or cell. For example, say I have 3 columns (id, name, and age) and 2 rows. If I wanted to get the name located in Row 2 Column 2, and set the caption of a label in my form to this name in Row 2 Column 2, how do I do it?
Thanks!
How To Set The Value To Specific Cell In DataGrid By Programmin?
I use VB 6 to implement project codes which use Datagrid to present information from database. The Datagrid allows user to modify, delete and add information and under some events I want to set value in specific cell by code such as at cell of first column and third row. How to do it? Thanks!
Insert Information Into A Specific Datagrid Cell
I am using a datagrid connected to an SQL server via an ADO connection.
I need to be able to insert a value into a hidden datagrid field via code. How can I do this?
Example:
I am displaying the data in a datagrid. I have set the visibility of the Payrate field to false, for security purposes. Now what I want to happen via code. When the user adds a record to the datagrid they enter the machine number in it's cell. I will use an SQL statment to get the payrate for that particular machine. (I can get this to work). Now for the real problem. How can I set the payrate cell in the added record to the payrate for that machine number.
If this is not clear e-mail me or post any questions you have of me.
If anyone can help with this... I thank YOU.
How To Pick Specific Records To Plot From .mdb Using MSCHART
Hi!
I have database in .mdb file..i m successfully develop code for ploting the data from 1st row of record to last record..but now i don know if i have to plot some middle records from database...some specific records ..then how this can be done...guide me if anyone has an idea...how i can put a criteria for plotting ...i m using MSCHART controll...
thanx in advance..
bye
How TAB Key Used In The DataGrid Control For Shifting Cell By Cell
Hello Friends,
I am using DataGrid Contol in my Application to Enter the data and the DataGrid is associated with the RecordSet of the Adodb and it is directly add and update the data.
Now my Problem is how can i go from on cell to another by pressing TAB key.
-Waiting For your Suggetions.
How Do I Get VB To Go To The Last Cell, Not A Specific Cell
sorry guys, im sure this isnt rocket science to you, but this is driving me mad!
The below is a section of code im writing, but the basic principal i am trying to achieve is to go to the bottom of a list of data and then autosum. The thing is i dont want it to use a specific cell, as the amount of data in the column will change.
What am i doing wrong?
Columns("K:K").Select
Selection.FindNext(After:=ActiveCell).Activate
Columns("K:K").Select
Range("K100").Activate
ActiveCell.FormulaR1C1 = "=SUM(R[-98]C:R[-1]C)"
Columns("K:K").Select
Range("K100").Activate
Thanks Dom
Find The Last Cell In A Col With A Specific Value
Hi all,
say I have a list of values in a Column in a worksheet that looks something like:
Blah
Rhubarb
Twaddle
07981
07944
07866
Drivel
Fluff
Does anyone know a quick way to find the ROW NUMBER of the last value that starts 079? Obviously I can loop and stuff, but I was wondering if there was some in-built function that would do this. I have to do this sort of test many times, and looping and testing all the cells seems like a good way to slow this thing to a crawl.
Cheers in advance
J.
Run Macro On Specific Cell Change
Is there a way to have a VB Macro run when a specific cell changes value ? I am able to have a macro run when a "sheet data change" takes place, but do not know how to isolate a specific cell to be watched, while ignoring any other changes to the sheet.
Thanks in advance for any help !!!
Select Specific Cell Range
Microsoft Excel 2003
Microsoft Visual Basic 6.3
Hello,
I am trying to make my macro select a range of cells whose row numbers are calculated within the macro.
Unfortunately the method I used doesn't seem to work, it tells me there is a 'Run time error 1004' and the debugger goes to the offending line (the second line of code shown below).
I originally recorded the macro, and then edited it to be able to automatically select a different range.
I originally had:
Range("B34:B37").select
And changed it to:
Range("B[(p + 1) - (r - 1)]:B[p + 1]").select
p & r are both defined beforehand and set equal to numeric values which depend on certain other factors.
This is probably a ridiculous way of going about it and I know very little about programming, but if anyone knows the correct way then I could REALLY use some help.
Thanks,
Henry
To Copy Specific Cell From 2 Workbook
Hi,
I would like to copy specific cell data from 2 workbook to another workbook(which is already existing).I am using VBA for excel. I would like to have the commands button only on the first workbook, without opening the 2nd and 3rd workbook. Can i fetch a cell data from 2nd workbook and write to the 3rd workbook.
Thanks in advance.
** RESOLVED ** Boldface Specific Cell In Flexgrid. Possible ?
Can anyone tell me what combination of .Cell, .Row, .Rowsel, .Colsel I ned to boldface a specific cell i a flexgrid ?
Ideally I would like to boldface specific rows.
I know it can be done, I just haven't hit the right combination yet, and its doing my head in
Problem To See Specific Data In Excel Cell Via VB6
Hello all,
I have a very wierd problem.
I have an Excel file, that looks normaly
I have data in the cells. that I can see while activate the
Excell Program, can manipulate that data... like Cut paste ac..
But when I go into my VB project..
Some of the Cells I see an NULL.. its a problematic subject for me..
I tried it all...can somebody help me????/
This is the code and attach is the Excell file.
The file is Excell2000. Maybe I open the File incorrect in VB..?
Maybe Do you have some triks that I can do?
When I use the Record Count I see all Records.
When I go on F3 some of the Data apears as NULL
(For example : 18112 on its second apearence) even thou I
can see the Data on the excel program.
Thanks in Adnvace
Eran.
Here is the Code:
Public Function fOpen_ConnDBExcelFrmActive()
'Connect to the Excel DB
'Created by Rinat Sade - iDnext Ltd.
'
On Error GoTo function_error
Dim objData As New CDBData
Dim pszConnection As String
Dim pszDataBase As String
Set objCn = New ADODB.Connection
If objCn.State = adStateOpen Then
If objRs.status = 1 Then
objRs.Close
Set objRs = Nothing
End If
objCn.Close
End If
Dim glTheError As Long
'get string connection
'Paste the correct Excel File here !!
pszDataBase = frmActiveForm.txtExcelFile.Text
'glTheError = objData.fGetDBConnection(11, pszDataBase, "")
pszConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & pszDataBase & _
"; Extended Properties=""Excel 8.0;HDR=No;"""
'Open connection
objCn.Open pszConnection
Set objData = Nothing
Dim pszString As String
Set objRs = New ADODB.Recordset
If objRs.State = adStateOpen Then
objRs.Close
End If
objRs.CursorType = adOpenStatic
' Use client cursor to allow use of
' AbsolutePosition property.
objRs.CursorLocation = adUseClient
' Open the recordset
pszString = "[" & frmActiveForm.txtTable.Text & "]"
objRs.Open pszString, objCn, adOpenStatic, adLockOptimistic
Debug.Print "Number of Records : "; objRs.RecordCount
Do While Not objRs.EOF
If Len(objRs.Fields("f3").Value & "") <> 0 Then
Debug.Print objRs.Fields("f3").Value
End If
objRs.MoveNext
Loop
Exit Function
function_error:
Debug.Print err.Description, err.Number
End Function
How To Search For Data In The Worksheet By Specific Cell Name
First of all, I'd like to apologize if I post this topic in wrong forum. I'm a newbie for VB and now I got one project which has to be implemented in VB.
In my project, I've to write the program to fill in the data in specific cell name in excel spreadsheet. But until now it doesn't work
For example, I've data in range A1:C10 which I've one cell named 'Address', not the value of that cell, which I'd like to fill data in. Firstly, I specified the range in the spreadsheet by using
Set rng = myWorksheet.Range("A1:C10")
then I wanna find where the cell named 'Address' is but I've no idea how to do it. Anybody has and idea? I tried with the command 'Find'
Set rngFound = rng.Find(xxxxxxx, ,yyyyyy , Excel.XlLookAt.xlPart, _
Excel.XlSearchOrder.xlByRows, Excel.XlSearchDirection.xlNext, _
False)
but I don't know which parameter I'd pass to this function. Could you pls help me finding out?
Thanks in advance
Change Back Color Of A Specific Cell In A Msflexgrid
In a msflexgrid, can I set a cell's back color similarly to the textmatrix property for text? I could use the cellbackcolor property but I want to do it without setting the row and col properties to those of that specific cell, i.e. without changing the current row and col values.
Copying A Cell From A Datagrid To Another Datagrid
My question is how to copy a datagrid cell to another datagrid cell?
for example; datagrid1 column 1, row 1 to datagrid2 column 2, row 3
I use
DataGrid1.Columns(1).CellValue(DataGrid1.RowBookmark(1)) to capture the value, but I don't know the expression how to copy to datagrid2
Thanks
Conditional Formatting In Excel Based On Specific Cell Updates
Hello,
I am creating an excel spreadsheet to track work progress and am having difficulty in setting up some conditional formatting on a column.
I have a header column as below:
Owner Coded Reviewer Review Number Status
Now underneath each of the above column headers, the data entered in each of the cells has an effect on what happens in the status column.
The status column has the following formaul entered in each cell:
Code:
=IF(J4<>"",IF(K4>=1,IF(M4<>"",IF(N4<>"","Ready for Rework (Post Review)","Review in Progress"),"Ready for Review"),"Schedule in Progress"),"Not Started")
Now for each of the 5 states which the formula can set in the status column I want to associate a colour - different to each other.
To do this i have created the following VBA:
Code:
Sub UpdateStatusColumn2()
Dim s As String
For Each c In Worksheets("Sheet3").Range("O2:O909").Cells
s = c.Value
Select Case s
Case s = "Not Started"
c.Activate
With Selection.Interior
.ColorIndex = 3
.Pattern = xlSolid
End With
Case s = "Schedule in Progress"
c.Activate
With Selection.Interior
.ColorIndex = 38
.Pattern = xlSolid
End With
Case s = "Ready for Review"
c.Activate
With Selection.Interior
.ColorIndex = 36
.Pattern = xlSolid
End With
Case s = "Review in Progress"
c.Activate
With Selection.Interior
.ColorIndex = 40
.Pattern = xlSolid
End With
Case s = "Ready for Rework (Post Review)"
c.Activate
With Selection.Interior
.ColorIndex = 46
.Pattern = xlSolid
End With
Case s = "Closed"
c.Activate
With Selection.Interior
.ColorIndex = 35
.Pattern = xlSolid
End With
End Select
Next
End Sub
My spreadsheet has almost 1000 rows and hence I do not want this to check every row when called.
What I want is for when the Owner, Coded, Reviewer, Review Number, or Status cells are updated for a particular row, then the above procedure UpdateStatusColumn2 is ran only on the same row for the cell in the Status column.
How do I do this? I know the for loop a the start will require updating as it will now no be required, but how do I get VBA to run the procedure only a single row when a cell underneath Owner, Coded, Reviewer, or Review Number is modified?
I should also say that I tried to use the Conditional Formatting within the Format menu but it only lets me use 3 conditions - which is not enough
I would appreciate all help offered.
Thanks,
W.
VB6, Entering Data Into MS Access DB, But Into A Specific Cell. Include Screenshots
Hi, my problem is that im making an application similar to a hotel management system(ive already seen source code of others on the net) but for a hospital.
Code:
If cmdOCCL1.Caption = "Occupy" Then
Set rs = Con.Execute("Insert into Ward1(RoomNo, FullName) " & _
"Values('" & 1 & "','" & txtPName1 & "')")
with this code its entering into the database table the room no which is 1 and the patients name from the txtbox.
But what i want to do is have the numbers already in the database say 1 - 20.
but the command button must add that name specifically into the row with room no. 1.
so i cant figure how to specifically add data to a specific row or cell type thing.
because say i do room 1 and the patients name goes next to room 1, then i do room 7 it will just stack one after another putting the patients name from room 7 next to room 2.
so names just stack or go in one after another.
so i'd like to figure how to put it in the specific cell or row and also how to have max room no's or rows kept at 20.
thx all help appreciated.
What To Pick What To Pick :confused:
Can anyone give reasons why one should pick either an:
out of process activeX exe,
or in process activeX dll?
Is there any good resources also that you may have run across on the web?
Selecting Specific Row From The Datagrid
Hello
i am using datagrid in my program to show all the record in the database
i am not being able to find the way that i click on one row and the record on that row come in the textboxes
tell me the easiest way and with simple example
thankyou
Refresh DATAGRID (SPECIFIC)
Hi!! i try to refresh the datagrid where my data from database are!! i need to refresh only that record where i made the changes, not all datagrid, becouse then the ACTIVE record again is first, but i need that the Active record is the same after refreshing datagrid!!
Search Datagrid For Specific String
I use Visual Basic Version 6, SP5.
I have a Datagrid that I use dynamically, the values will not reflect the database. I do need to search for either the string, "Pass or Fail", in lower or upper case, in columns 1 through 8, all rows. I looked everywhere on this site and could not find a example.
If the string is found, I just need to copy the information to a text box.
THX in advance.
BC
Adding A Row At A Specific Location In DataGrid
How to add a row at specific location in DataGrid OR FlexGrid Control,
eg. Consider a DataGrid OR FlexFrid control with 10 records, i want to add a row after 5th record.
How this can be done ?????????
Printing Specific Rows In A Datagrid
Im trying to print rows in a datagrid, the code I am using:
Dim varBmk As Variant
For Each varBmk In Grid1.SelBookmarks
Grid1.Row = varBmk - 1
Grid1.Col = 0
strTemp = (Grid1)
PrintTextOnPrinter 12, RowNumber, strTemp
Grid1.Col = 1
strTemp = (Grid1)
PrintTextOnPrinter 44, RowNumber, strTemp
Grid1.Col = 2
strTemp = (Grid1)
PrintTextOnPrinter 76, RowNumber, strTemp
next
The code above works fine but only for yhe first few rows in the datagrid, if I try and print the rows further down the datagrid the bookmark seems to jump to the bottom of the grid and prints the last record instead of the one i clicked on.
Please someone show me where I am going wrong!!
Edited by - Paul_D on 6/30/2004 2:07:23 AM
Populating A Datagrid Relating To A Specific Value
my datagrid is bound to a table called OrderDetails. this table contains the following fields:
OrderNo (PK), ProductCode(also PK), ProductDesc, Quantity, Price.
the datagrid displays all the fields in the table, except order number. Records are added incrementally to the table (hence, also the datagrid) when a button is pressed. however, i want it to display only records relating to a specific OrderNo (ie the value in the textbox txtOrderNo.Text). how would i go about this? i have tried tying it to a SQL statement but i am very unsure of the syntax, as you can see from the following snippet:
Dim tSQL
tSQL = "Select ProductCode, ProductDesc, Quantity, Price From OrderDetail Where OrderNo = " & iOrderNo & ""
Set RS = Conn.Execute(tSQL)
Set DataGrid2.DataSource = RS
MsgBox ("Adding record to the datagrid")
Me.Adodc2.Refresh
Me.DataGrid2.Refresh
Thanks in advance!
Datagrid Calculate Value In Specific Column
Hi,
How can you calculate the total of values from one specific column into a datagrid and return that value into text field automatically?
Here the fact...
I'm using Master/Detail Form..
Master fields are:
- phaseID
- Phase
- Totaltime
Detail fields are:
- timeID
- phaseID
- Time
So, i want to calculate the sum of Time and return the value into Totaltime.
Thanks for help !
Opening Excel, Selecting Book / Sheet - Read/write Data To/from Specific Cell Usinf WIN 3A
Please can someone inform me how to do the following using Win32 API functionds onlyl;
1) open excel
2) open a named bookbook and select specific sheet
3) read or write an entry into or out of a specific cell;
I have opend other programs before from a VB6 environment using shell execute statement, however in this problem I am not using VB6, rather a prorietary programming language that allows me to have access to WIN 32 API functions - so my problem has to be solved using these functions only.
Any one's help on this probelm is greatly appreciated.
Regards
adam
Find And Select A Specific Row In DataGrid Control In VB6.
In code I need to find, select and highlight a specific row in a DataGrid control based on the value of a specific field (column) in the grid. Iterating through the rows using .Row is unacceptable because .Row only deals with visible rows and the row being sought may not be visible. Ideas?
DataGrid's Specific Column Keypress Event
Hi!
i am using DataGrid to display records. I want to update records by editing. in one specific column(Ex: Status) the default data is 'P' . when i press 'c' i want to control the keypress as upper case. Means if i press 'c', it should become 'C'. then i want to check it in beforecolupdate event.
Private Sub DataGrid1_KeyPress(KeyAscii As Integer)
Dim Char As String 'C=67
Char = Chr(KeyAscii)
KeyAscii = Asc(UCase(Char))
End Sub
Private Sub DataGrid1_BeforeColUpdate(ByVal ColIndex As Integer, OldValue As Variant, Cancel As Integer)
Dim sR$, sC$ 'C=67 'R=82
Dim colpos As Byte
sR = Chr(82)
sC = Chr(67)
colpos = (DataGrid1.Columns("Status").ColIndex)
If ColIndex = colpos Then
If ((DataGrid1.Columns("Status").Value <> sC) And (DataGrid1.Columns("Status").Value <> sR)) Then
Cancel = True
MsgBox "You must enter either 'C' OR 'R' only.", vbCritical, "Error in Entry"
End If
End If
End Sub
the problem is keypress event works for all colums. BeforeColUpdate event is also not working as i want.
if i modify only Status column then, BeforeColUpdate event is working.
So my question is how to control one specific column's value to upper and check it, because i am modifying 3 columns and checking only one column.
except this problem update is working . only thing is i have to enter Capital 'C' manually.
Help me
thanks
>>>>>>>>>>>>>>>>>
Edited by - sreddy on 4/5/2005 9:18:41 AM
Is It Able To Merge Specific Cells Of Datagrid Control ?
dear all,
i wonder, is it able to merge cells of datagrid control ?
i am building an inventory application in vb6 with SQL Server as DBMS.
i want to deliver the data like this :
Code:
-------------------------------------------------------------
TransID | Customer | Products Bought |
-------------------------------------------------------------
T0001 | Jane | Sugar, Candy |
-----------------------------------------------
| John | Shoes, short, T Shirt |
-------------------------------------------------------------
T0002 | Mandy | Mouse, KeyBoard |
| | Memory, Processor |
-----------------------------------------------
| Jessica | Monitor, DVD, Speaker, |
| | SoundCard, VGA CArd |
------------------------------------------------
| Joan | Toshiba Laptop |
--------------------------------------------------------------
T0003 | Carrie | Groban VCD, Ball, Table |
-------------------------------------------------------------
is it possible to build such view using DataGrid ? or
maybe there is another way to build such this not using DataGrid ?
Thnx in advance
rgrds,
Szpilman
How To Next Cell On Datagrid
next record.JPG
On every cell if I press ENTER then the cursor go to the next cell,
and if cell is the last cell then the cursor go to the next record
how to do that on VB 6
Getting The Sum In Datagrid Cell
hello there!
how do i get the sum in datagrid e.g in cell(2) values are:
600
700
200
total=1500
adodc1.recordsource ="select * from mytable where id_no=2"
then i will pass sum in the label1.caption = total in datagrid.cell(8)
tnx a lot
How To Get The Value Of A Particular Cell In Datagrid
Hi,
I have a data grid which populates values from a table. I need the cell value of the datagrid to use it for some other purpose.
I did this, but it seems to only give the cell number and not the value
VB Code:
MsgBox "Cell(" & pricing.Row & ", " & pricing.Col & _ ") " pricing.SetFocus
I tried this, but looks like it is for the datagrid web control
VB Code:
s = pricing.Items(0).Cells(1).TextMsgBox s
Please help
Set A Value In A DataGrid Cell
I work in VB6 with a DataGrid control. I try to validate data in a BeforeColUpdate event of DataGrid. When the value is wrong I want to correct the value. I use the folowing statement, like in VB Help documentation:
DataGrid1.Columns(ColIndex).Value=correct_value
but this statement doesn't work - it does nothing, the old value remains.
How can I set a value in a DataGrid column ?
Cell Datagrid
how can i change just a cell background in datagrid?
Datagrid Cell
I have a dataGrid.
what i'm trying to do is when i use my down arrow, the row in dataGrid will be selected
from column 1 to the last column.
what i have done is to use dataGrid1.selStartCol and dataGrid1.selEndCol but this is fr the column.
how to make for just one row at a time ?
Thanks
DataGrid Cell Edit
Hi,
I need help using a datagrid. I'm trying to edit a cell's value during runtime. I have the following code in my datagrid's double click event:
With DataGrid1
.Columns(.Col).Value = "Value1"
End With
But the datagrid does not work. I think it's probably locked or something.
Any help would be appreciated. Thanks.
Datagrid Cell Exclution
Hi,
I have tried different ways of stopping a user from entering a particular Cell in a datagrid, I can get it so the user clicks the cell and can not alter the data but can not stop the cell from highlighting, is this possible.
|