PDA

View Full Version : Datagrid Frustrations


rob225
12-30-03, 10:44 PM
OK, here is what I have. I populate a datagrid on form load with the following code:

Sub FillWeightArc()

Set connW = New adodb.Connection

connW.CursorLocation = adUseClient
connW.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & App.Path & "\sld32.mdb;" & ";" & "Jet OLEDB:Database Password=ice" _



Set rsW = New adodb.Recordset
rsW.Open "SELECT [WeighIn Date], Height, Weight,[Authorized Weight],[Body Fat %], [Authorized Body Fat %] from Weight WHERE SSN = " & """" & txtSSN.Text & """", connW, _
adOpenStatic, adLockOptimistic

rsW.Sort = "[WeighIn Date] desc"


With DataGrid2

.Caption = "Weigh In History"


Set .DataSource = rsW

.Columns(0).Width = 1000
.Columns(1).Width = 650
.Columns(2).Width = 650
.Columns(3).Width = 1400
.Columns(4).Width = 900
.Columns(5).Width = 1710

.Columns(0).Alignment = dbgCenter
.Columns(1).Alignment = dbgCenter
.Columns(2).Alignment = dbgCenter
.Columns(3).Alignment = dbgCenter
.Columns(4).Alignment = dbgCenter
.Columns(5).Alignment = dbgCenter

.Columns(0).NumberFormat = "DD MMM YY"
End With


End Sub

I have another form I use to add data to the DB table and use the following code to add the data to the DB:

rs13.AddNew
rs13.Update 'create and save new (empty) record
rs13.Bookmark = rs13.LastModified 'move to new record

'rs4.MoveLast
rs13.Edit

rs13![WeighIn Date] = frmWeightEntry.Text1.Text
rs13!Height = frmWeightEntry.Text2.Text
rs13!Weight = frmWeightEntry.Text3.Text
rs13![Authorized Weight] = frmWeightEntry.Text4.Text
rs13![Authorized Body Fat %] = frmWeightEntry.Text5.Text
rs13![Body Fat %] = frmWeightEntry.Text6.Text
rs13!SSN = frmMain.txtSSN.Text

rs13.Update

frmMain.FillWeightArc

Unload Me
Unload frmWeightEntry

The data loads fine on program start up. The form I use to add data to the DB works fine. Now the problem I have is updating the datagrid AFTER I have added new data. It does not immediately display the data in the datagrid, I have to move off the record and back again for the new data to appear in the datagrid.

Please, Oh please someone help me out here. I have been experimenting with this for at least 6 months and each time get frustrated with it and just quit. I have tried the rebind, refresh, etc anything I can think of. I am up for any solutions here, if I have to change my layout then so be it, I just need to be able to get this working.

Thanks,

Robert

Acecool
01-02-04, 12:29 AM
Try making a timer if it has to update often.