Thread Solved
Reply

Join Date: Dec 2008
Posts: 287
Reputation: firoz.raj is an unknown quantity at this point 
Solved Threads: 1
firoz.raj firoz.raj is offline Offline
Posting Whiz in Training

kindly help me

 
0
  #1
Dec 16th, 2008
In a msflexgrid control , i want to give the option to the user to select a single row or a group of rows from msflex grid control the if
use clickon the product_id from first msflexgrid contrl1 since this
grid contains complete list of product_id it selected record should
come on another msflexgrid2
Kindly help me.

i have written a code like that :
Private Sub Form_Load()
Set con = New Connection
con.Open ("Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=\\asfserver\itp$\Product_tabletest.mdb")
Me.Left = (Screen.Width - Me.Width) / 2
Me.Top = (Screen.Height - Me.Height) / 2
Combo1.AddItem "ADMIN & IT"
Combo1.AddItem "SALES"
Combo1.AddItem "ENGINEERING"
Combo1.AddItem "MAINTENANCE"
Combo1.AddItem "MANUFACTERING"
Combo1.AddItem "FINANCE"
Combo1.AddItem "QUALITY CONTROL"
Text13.Locked = Not editing
MSFlexGrid1.FixedRows = 1
MSFlexGrid1.FillStyle = flexFillRepeat
MSFlexGrid1.ColWidth(0) = 1000
MSFlexGrid1.ColWidth(1) = 3500
MSFlexGrid1.ColAlignment(0) = 4
MSFlexGrid1.ColAlignment(1) = 4
MSFlexGrid1.ColAlignment(2) = 4
MSFlexGrid1.Row = 1
MSFlexGrid1.Col = 0
MSFlexGrid1.RowSel = 5
MSFlexGrid1.Cols = 10 'Set dimensions of flexgrid and set selection behaviour
MSFlexGrid1.Rows = 10 'displaying grid
On Error Resume Next
MSFlexGrid1.CellFontBold = True
MSFlexGrid1.CellAlignment = 4
MSFlexGrid1.Font = "Arial"
MSFlexGrid1.TextMatrix(0, 0) = "Product_id"
MSFlexGrid1.TextMatrix(0, 1) = "Product_name"
MSFlexGrid1.TextMatrix(0, 2) = "Unit"
MSFlexGrid1.TextMatrix(0, 3) = "Quantity"
Dim R, C
Set rs = New Recordset
rs.CursorLocation = adUseClient
rs.Open "select distinct item_code,Productname,unit from partdetail ", con, adOpenDynamic, adLockOptimistic
If rs.RecordCount > 0 Then
Do Until rs.EOF
R = R + 1
For C = 0 To 4 Step 1
MSFlexGrid1.Rows = rs.RecordCount + 1
MSFlexGrid1.TextMatrix(R, C) = rs.Fields(C).Value
Next
rs.MoveNext
Loop
End If
End Sub
Attached Files
File Type: doc Assistence.doc (66.0 KB, 6 views)
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 848
Reputation: QVeen72 is on a distinguished road 
Solved Threads: 120
QVeen72's Avatar
QVeen72 QVeen72 is offline Offline
Practically a Posting Shark

Re: kindly help me

 
0
  #2
Dec 16th, 2008
Hi,

Place a CommandButton "Populate" in the Frame,
Initially, Make Grid2.Rows = 1.

Select a Row, in First Grid, and Click On "Populate", write this code for commandClick.

  1. Dim i As Integer
  2. If Grid1.Row > 0 Then
  3. Grid2.Rows=Grid2.Rows+1
  4. With Grid2
  5. .TextMatrix(.Rows-1, 0) = Grid1.TextMatrix(.Row,0)
  6. .TextMatrix(.Rows-1, 1) = Grid1.TextMatrix(.Row,1)
  7. .TextMatrix(.Rows-1, 2) = Grid1.TextMatrix(.Row,2)
  8. .TextMatrix(.Rows-1, 3) = Grid1.TextMatrix(.Row,3)
  9. End With
  10. End If

Regards
Veena
Last edited by QVeen72; Dec 16th, 2008 at 5:39 am.
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 287
Reputation: firoz.raj is an unknown quantity at this point 
Solved Threads: 1
firoz.raj firoz.raj is offline Offline
Posting Whiz in Training

Re: kindly help me

 
0
  #3
Dec 16th, 2008
as per your suggestion i have written a code in populate_click
Private Sub populate_Click()
MSFlexGrid2.Row = 4
Dim i As Integer
If MSFlexGrid1.Row > 0 Then
MSFlexGrid2.Rows = MSFlexGrid2.Row + 1
MSFlexGrid2.TextMatrix(MSFlexGrid1.Row - 1, 0) = MSFlexGrid1.TextMatrix(MSFlexGrid2.Row, 0)
MSFlexGrid2.TextMatrix(MSFlexGrid1.Row - 1, 1) = MSFlexGrid1.TextMatrix(MSFlexGrid2.Row, 1)
MSFlexGrid2.TextMatrix(MSFlexGrid1.Row - 1, 2) = MSFlexGrid1.TextMatrix(MSFlexGrid2.Row, 2)
MSFlexGrid2.TextMatrix(MSFlexGrid1.Row - 1, 3) = MSFlexGrid1.TextMatrix(MSFlexGrid2.Row, 3)
End If
End Sub

but when i select multiple record got error Subscript out of range
Run time error 381

Kindly help me
Attached Files
File Type: doc sample.doc (66.0 KB, 1 views)
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 848
Reputation: QVeen72 is on a distinguished road 
Solved Threads: 120
QVeen72's Avatar
QVeen72 QVeen72 is offline Offline
Practically a Posting Shark

Re: kindly help me

 
0
  #4
Dec 16th, 2008
Hi,

You have messed the code..
change to :

MSFlexGrid2.TextMatrix(MSFlexGrid1.Rows - 1, 1 ) = MSFlexGrid1.TextMatrix(MSFlexGrid2.Row, 1)

Also, why you are hardcoding rows=4..?
MSFlexGrid2.Row = 4 ' -->> Why This Line..?

Regards
Veena
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 287
Reputation: firoz.raj is an unknown quantity at this point 
Solved Threads: 1
firoz.raj firoz.raj is offline Offline
Posting Whiz in Training

Re: kindly help me

 
0
  #5
Dec 16th, 2008
Private Sub Command5_Click()
Dim i As Integer
If MSFlexGrid2.Row > 0 Then
MSFlexGrid2.Rows = MSFlexGrid2.Row + 1
MSFlexGrid2.TextMatrix(MSFlexGrid1.Rows - 1, 0) = MSFlexGrid1.TextMatrix(MSFlexGrid2.Row, 0)
MSFlexGrid2.TextMatrix(MSFlexGrid1.Rows - 1, 1) = MSFlexGrid1.TextMatrix(MSFlexGrid2.Row, 1)
MSFlexGrid2.TextMatrix(MSFlexGrid1.Rows - 1, 2) = MSFlexGrid1.TextMatrix(MSFlexGrid2.Row, 2)
MSFlexGrid2.TextMatrix(MSFlexGrid1.Rows - 1, 3) = MSFlexGrid1.TextMatrix(MSFlexGrid2.Row, 3)
End If
End Sub

since i am checking If MSFlexGrid2.Row > 0 Then
that is why i put msflexgrid2.row=4

right now i am getting run time error 381
help me please .
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 848
Reputation: QVeen72 is on a distinguished road 
Solved Threads: 120
QVeen72's Avatar
QVeen72 QVeen72 is offline Offline
Practically a Posting Shark

Re: kindly help me

 
0
  #6
Dec 16th, 2008
CHANGE SECOND LINE TO :

MSFlexGrid2.Rows = MSFlexGrid2.Rows + 1

Everytime, you populate a row is added..

Regards
Veena
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 287
Reputation: firoz.raj is an unknown quantity at this point 
Solved Threads: 1
firoz.raj firoz.raj is offline Offline
Posting Whiz in Training

Re: kindly help me

 
0
  #7
Dec 16th, 2008
which second line i changed second line is already :
MSFlexGrid2.Rows = MSFlexGrid2.Rows + 1
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 848
Reputation: QVeen72 is on a distinguished road 
Solved Threads: 120
QVeen72's Avatar
QVeen72 QVeen72 is offline Offline
Practically a Posting Shark

Re: kindly help me

 
0
  #8
Dec 16th, 2008
Hi,

Again you have messed up the code.. Why cant Copy My Code neatly....?

Regards
Veena
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 287
Reputation: firoz.raj is an unknown quantity at this point 
Solved Threads: 1
firoz.raj firoz.raj is offline Offline
Posting Whiz in Training

Re: kindly help me

 
0
  #9
Dec 16th, 2008
i am sending my .frm form
kindly comment the code
which is wrong.
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 287
Reputation: firoz.raj is an unknown quantity at this point 
Solved Threads: 1
firoz.raj firoz.raj is offline Offline
Posting Whiz in Training

Re: kindly help me

 
0
  #10
Dec 16th, 2008
Did you get my zip file
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC