By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,806 Members | 1,506 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,806 IT Pros & Developers. It's quick & easy.

MSFLEXGRID problem

P: 9
Hi...

Below is my code:

Expand|Select|Wrap|Line Numbers
  1. Dim trs As New ADODB.Recordset
  2. Public cn As ADODB.Connection
  3.  
  4.  
  5. Public Sub databaseconnect()
  6. Set cn = New ADODB.Connection
  7. cn.Open "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=hrms;Data Source=."
  8. End Sub
  9.  
  10.  
  11. Private Sub Combo1_Click()   ' pcode
  12.  
  13. Do While MSFlexGrid1.Rows > 1
  14.  MSFlexGrid1.RemoveItem (MSFlexGrid1.Rows)
  15. Loop
  16.  
  17. If Combo1 <> "" Then
  18. trs.Open "select * from prjmaster where pcode = '" & Combo1 & "'", cn
  19. Label7 = trs.Fields(1)
  20. trs.Close
  21. End If
  22.  
  23. trs.Open "select empid from prjtrans where pcode='" & Combo1 & "'", cn
  24.  
  25. Dim ers  As Recordset
  26.  
  27. Do While Not trs.EOF
  28.  
  29. If trs.RecordCount > 0 Then
  30. ers.Open "select empname from empmaster where empid= " & trs.Fields(0), cn
  31.  
  32.            MSFlexGrid1.AddItem ("")
  33.            MSFlexGrid1.Col = 1
  34.            MSFlexGrid1.Row = MSFlexGrid1.Rows - 1
  35.            MSFlexGrid1.Text = trs.Fields(0)
  36.            MSFlexGrid1.Col = 2
  37.            MSFlexGrid1.Text =ers.Fields(1)
  38.            End If
  39.            trs.MoveNext
  40.            Loop
  41.   trs.Close
  42. End Sub
  43.  
  44. Private Sub Combo2_Click()           'empid
  45. If Combo1 <> "" Then
  46. trs.Open "select * from empmaster where empid = " & Combo2, cn
  47. Label9 = trs.Fields(1)
  48. trs.Close
  49. End If
  50. End Sub
  51.  
  52.  
  53. Private Sub Command1_Click()           'ADD BUTTON
  54. trs.Open "select pcode from prjtrans where pcode = '" + pcode + "'" + "and empid =" + Combo2, cn
  55. cn.Execute "insert into prjtrans values('" & Combo1 & "'," & Combo2 & ",'" & DTPicker1.Value & "','" & DTPicker2.Value & "','" & Combo3.Text & "')"
  56.  
  57.  
  58.             MSFlexGrid1.AddItem ("")
  59.             MSFlexGrid1.Col = 1
  60.             MSFlexGrid1.Row = MSFlexGrid1.Rows - 1
  61.             MSFlexGrid1.Text = Combo2.Text
  62.             MSFlexGrid1.Col = 2
  63.             MSFlexGrid1.Text = Label9
  64.  
  65.             trs.Close
  66.  
  67. End Sub
  68.  
  69.  
  70. Private Sub Form_Load()
  71. Call databaseconnect
  72.  
  73. trs.Open "select * from prjmaster", cn
  74. Do While Not trs.EOF
  75. Combo1.AddItem trs.Fields(0)
  76. trs.MoveNext
  77. Loop
  78. trs.Close
  79.  
  80. trs.Open "select * from empmaster", cn
  81. Do While Not trs.EOF
  82. Combo2.AddItem trs.Fields(0)
  83. trs.MoveNext
  84. Loop
  85. trs.Close
  86.  
  87. Combo3.AddItem "Group Leader"
  88. Combo3.AddItem "Group Member"
  89.  
  90.  
  91.  
  92. MSFlexGrid1.ColWidth(0) = 0
  93. MSFlexGrid1.ColWidth(2) = 1800
  94.  
  95. MSFlexGrid1.Col = 1
  96. MSFlexGrid1.Row = 0
  97. MSFlexGrid1.Text = "Emp ID"
  98.  
  99. MSFlexGrid1.Col = 2
  100. MSFlexGrid1.Row = 0
  101. MSFlexGrid1.Text = "Name"
  102.  
  103. End Sub

My problem is... the values inserted in the prjtrans table... cant get viewable in the flexgrid control while clicking the combo1...
By clicking command1... at tht time...the inserted value gets displayed in the flexgrid...

i cant able to retrieve..from prjtrans...to show in flexgrid while clicking combo1...


Pl...help me...

Sree,
Apr 28 '08 #1
Share this Question
Share on Google+
2 Replies


debasisdas
Expert 5K+
P: 8,127
Change your sql string to

"select * from prjmaster where pcode = '" & Combo1.list(combo1.listindex) & "'"

also try to execute on Change event of the combo.
Apr 29 '08 #2

P: 9
Hi..

Thks a lot...

Sree..
Apr 29 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.