-
Feb 22nd, 2006, 04:10 PM
#1
Thread Starter
Addicted Member
MSHFlexGrid showing wrong data when filled 2x
Ok, I have a txt box and when the textbox text changes its supposed to run an sql statement to fill the mshflexgrid. Which it does. BUT when you search more than once (without closing the frm in between)then click a line in the flexgrid to select a record it gives you the data for the line above the one you clicked...
Im thinking the mshflexgrid isnt resetting or something in between. I tried the refresh property, the redraw property, the clear & Clear structure properties, etc. I dont know what else I can do.
Here is my code to fill the mshflexgrid...
VB Code:
Dim sConnect As String
Dim sSQL As String
Dim dfwConn As ADODB.Connection
Dim datPrimaryRs As New ADODB.Recordset
'set strings
sConnect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='" & frmlocation.Text1.Text & "';Persist Security Info=False"
sSQL = "select InsRecID, SpecID, Insurance, InsuranceID from DrsInsuranceList where SpecID like '" & Text7.Text & "'"
' open connection
Set dfwConn = New ADODB.Connection
dfwConn.Open sConnect
'create a recordset using the provided collection
datPrimaryRs.CursorLocation = adUseClient
datPrimaryRs.Open sSQL, dfwConn, adOpenForwardOnly, adLockReadOnly
Set MSHFlexGrid1.DataSource = datPrimaryRs
With MSHFlexGrid1
.ColWidth(0) = 250
.ColWidth(1) = 0
.ColWidth(2) = 1500
.ColWidth(3) = 1500
.ColWidth(4) = 1500
.ColAlignment(1) = 4
.ColAlignment(3) = 4
.ColAlignment(4) = 4
.ColAlignmentFixed = 4
.Row = 0
.Col = 2
.Text = "Specialist ID"
.Col = 3
.Text = "Insurance"
.Col = 4
.Text = "Insurance ID"
End With
Ideas?
-----MY SITES-----
BayRidgeNights.Com - NYC Nightlife Forums
Fight Communism - Rate Posts!
-
Feb 22nd, 2006, 04:45 PM
#2
Thread Starter
Addicted Member
Re: MSHFlexGrid showing wrong data when filled 2x
Ok... I semi-fixed it.
I added a
But I also had to add a "On error resume next" (Which im not happy about) because everytime I like past the last row in the grid it gave an error.
-----MY SITES-----
BayRidgeNights.Com - NYC Nightlife Forums
Fight Communism - Rate Posts!
-
Feb 22nd, 2006, 09:36 PM
#3
Re: MSHFlexGrid showing wrong data when filled 2x
I could not duplicate the problem using your code. Here is what I used against the Northwind database.
VB Code:
Private Sub Command1_Click()
Dim sConnect As String
Dim sSQL As String
Dim dfwConn As ADODB.Connection
Dim datPrimaryRs As New ADODB.Recordset
'set strings
sConnect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\projects\northwind2002.mdb;Persist Security Info=False"
sSQL = "select CustomerId, CompanyName, Country, Region From Customers where CustomerId Like '" & Text1.Text & "'"
' open connection
Set dfwConn = New ADODB.Connection
dfwConn.Open sConnect
'create a recordset using the provided collection
datPrimaryRs.CursorLocation = adUseClient
datPrimaryRs.Open sSQL, dfwConn, adOpenForwardOnly, adLockReadOnly
Set MSHFlexGrid1.DataSource = datPrimaryRs
With MSHFlexGrid1
.ColWidth(0) = 250
.ColWidth(1) = 0
.ColWidth(2) = 2500
.ColWidth(3) = 1000
.ColWidth(4) = 800
.ColAlignment(1) = 4
.ColAlignment(3) = 4
.ColAlignment(4) = 4
.ColAlignmentFixed = 4
.Row = 0
.Col = 2
.Text = "Company Name"
.Col = 3
.Text = "Country"
.Col = 4
.Text = "Region"
End With
End Sub
Private Sub MSHFlexGrid1_Click()
Debug.Print Me.MSHFlexGrid1.TextMatrix(Me.MSHFlexGrid1.MouseRow, 1), Me.MSHFlexGrid1.TextMatrix(Me.MSHFlexGrid1.MouseRow, 2)
End Sub
Is there any other code in other events that may be contributing to the problem?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|