Problem Updating My MSFlexgrid

I NEED EXPERTS HERE! LOL!

Page 1 of 1

7 Replies - 7586 Views - Last Post: 25 September 2008 - 07:13 PM Rate Topic: -----

#1 barakulyo1  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 29-August 08

Problem Updating My MSFlexgrid

Posted 23 September 2008 - 10:21 AM

okay, first i'll introduce the idea
the idea is to delete a data from a DataGrid, and then when a ccommand button is clicked, the MSFlexgrid will show and update its data.
NOTE: DataGrid and MSFlexgrid have the same contents or database.
db = Adodc1 Name (for DataGrid)
db1 = DAO Name (for MSFlexgrid)

THIS IS MY CODE FOR DELETING A DATA FROM DATAGRID:
Private Sub Command1_Click()
db1.Refresh
db.Recordset.Delete
db.Recordset.Update



THIS IS MY CODE FOR UPDATING MY MSFLEXGRID
Private Sub Command20_Click()
Dim x As Integer
Dim y As Integer
Dim z As Integer
MSFlexGrid1.Visible = True
DataGrid1.Visible = False
db1.Refresh
X = 1
Y = 1
Do Until X = db1.Recordset.RecordCount + 1
	MSFlexGrid1.Row = X
	If Y = 6 Then
		Y = 1
	Else
		Do Until Y = 6
			MSFlexGrid1.Col = Y
			If Not MSFlexGrid1.object > 0 Then
				Do Until z = 6
					MSFlexGrid1.Col = z
					MSFlexGrid1.CellBackColor = vbWhite
					z = z + 1
				Loop
				z = 1
			Else
				MSFlexGrid1.CellBackColor = vbYellow
			End If
			Y = Y + 1
		Loop
	Y = 1
	End If
	X = X + 1
Loop
X = 1
End Sub



I use DataGrid to delete data because i can easily delete a data by selecting and clicking a command button, i use MSFlexgrid to show my database because i can change the cellbackcolor to highlight some rows.

MY PROBLEM:
I can update my database MSFlexgrid, BUT!! only if i click the command button for MSFlexgrid many times, i think it is because on "db1.refresh" code, but my question is, why it doesn't upgrade the MSFlexgrid in just one click.

ALTERNATIVE:
If someone can show me a code for deleting a data from a MSFlexgrid by selecting a row, I can disregard the usage of DataGrid.

I hope you can understand my problem, although it's too long.. HEHEHE!!! :D

Is This A Good Question/Topic? 0
  • +

Replies To: Problem Updating My MSFlexgrid

#2 thava  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 180
  • View blog
  • Posts: 1,606
  • Joined: 17-April 07

Re: Problem Updating My MSFlexgrid

Posted 23 September 2008 - 10:58 PM

instead of datagrid use the dbgrid and update the same
like this

set msflexgrid.datasorce = db1
set dbgrid1.datasource =db1

when you delete the record in dbgrid it immediately update in the db1's recordset
now call your command20_click()
Was This Post Helpful? 0
  • +
  • -

#3 barakulyo1  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 29-August 08

Re: Problem Updating My MSFlexgrid

Posted 25 September 2008 - 10:17 AM

Hi thava :P

i put your instruction inside the command1 button. but i get this error message:

"Run-time error '91':
Object cariable or With block variable not set"

This is the code for command1:

Private Sub Command1_Click()
Set MSFlexGrid1.DataSource = db1
Set dbgrid1.DataSource = db
db1.Refresh
db.Recordset.Delete
db.Recordset.Update
End Sub



and please can you tell me what is the function of

Set MSFlexGrid1.Datasource = db1
Set dbgrid1.DataSource = db

Thanks for your concern :D
Was This Post Helpful? 0
  • +
  • -

#4 thava  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 180
  • View blog
  • Posts: 1,606
  • Joined: 17-April 07

Re: Problem Updating My MSFlexgrid

Posted 25 September 2008 - 06:37 PM

i said use a same recordset for Both grids

db and db1

wait some time i will thecode


here i found a solution
you dont need to use the dbgrid or datagrid just use the msflexgrid
Private Sub Command1_Click()
rs.FindFirst ("Empno = '" + MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 1) + "'")
rs.Delete
Data1.Refresh
End Sub


if you want to thank me just click the this post was helpful link

This post has been edited by thava: 25 September 2008 - 06:50 PM

Was This Post Helpful? 0
  • +
  • -

#5 barakulyo1  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 29-August 08

Re: Problem Updating My MSFlexgrid

Posted 25 September 2008 - 06:57 PM

But MSFlexGrid is only for DAO (db1)

and

DataGrid is only for ADO (db)

i use different recordset because of the compatibility
Was This Post Helpful? 0
  • +
  • -

#6 thava  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 180
  • View blog
  • Posts: 1,606
  • Joined: 17-April 07

Re: Problem Updating My MSFlexgrid

Posted 25 September 2008 - 07:02 PM

ok what type of databse do you use

and moreover you fill the msflexgrid by dao then why don't you use it

ok if you wnat to use the ado connection just use mshflexgrid(Hierarchical Flexgrid)

This post has been edited by thava: 25 September 2008 - 07:10 PM

Was This Post Helpful? 0
  • +
  • -

#7 barakulyo1  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 29-August 08

Re: Problem Updating My MSFlexgrid

Posted 25 September 2008 - 07:08 PM

OH MY GOSH!!!!!!!!!

hehehe

WOAH!!

thanks a lot bro!!!

:^:
Was This Post Helpful? 0
  • +
  • -

#9 thava  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 180
  • View blog
  • Posts: 1,606
  • Joined: 17-April 07

Re: Problem Updating My MSFlexgrid

Posted 25 September 2008 - 07:13 PM

Quote

thanks a lot bro!!!

if you want to thank me just click the this post was helpful link
Was This Post Helpful? 1

Page 1 of 1