MSFlex Grid Control Problem 
Author Message
 MSFlex Grid Control Problem

I am trying  to refresh the items loaded into a grid control after I add a
record.  The trouble is that it misses one record unless I 'step' through
the code one line at a time.  For instance:

1)  User adds a record, using the interface, to an access database
2)  The code calls a SaveRecord public sub which in turn calls a listrecords
sub

The listrecords sub is below.  I have included notes with the 'BLF' initials
to indicate.  I appreciate any help you could give.
Thanks!

Public Sub ListRecords()

On Error GoTo CourtListErr

Dim Conn7 As New ADODB.Connection
Dim Rs7 As ADODB.Recordset
Dim AccessConnect7 As String

AccessConnect7 = "Driver={Microsoft Access Driver (*.mdb)};" & _
                 "Dbq=" & dbFile & ";" & _
                 "DefaultDir=" & DataPath & ";" & _
                 "Uid=Admin;Pwd=" + AdminDatabasePassword & ";"
Conn7.ConnectionString = AccessConnect7
Conn7.Open
Set Rs7 = New ADODB.Recordset
Rs7.CursorLocation = adOpenKeyset
Rs7.LockType = adLockOptimistic
Rs7.Open "Select * from tblCourtInfo where AppKey='" & RecKey & "';", Conn7,
adOpenForwardOnly, adLockPessimistic

<**NOTES HERE**>
BLF- Here is where the trouble begins.  Ideally, when appmode =14, it is a
new record and therefore should display the messagebox below once.  However,
when another record is entered, rs7.eof and rs7.bof are both true and the
messagebox displays again.  Also, when there is more than 1 record, it does
not display the record that was just added unless the user exits the screen
and returns.  This problem only happens when I don't step through the code,
so I believe it to be a timing problem (i.e. the code works faster than the
data is saved in the database).  Does anyone have any suggestions?

If AppMode = 14 Then                                                ' Adding
from the wizard
    If Rs7.EOF And Rs7.BOF Then MsgBox "There are entries in the Court
Information Table for application: " & AppNo, vbInformation + vbOKOnly,
App.Title

    'Populate Table

    frmNewAppInfo4.MSFlexCrtInfo.Clear
    frmNewAppInfo4.MSFlexCrtInfo.Row = 1
    frmNewAppInfo4.MSFlexCrtInfo.FormatString = "AppNo |Date | Court | Room
| Time | Pending Court | Appeared"

    frmNewAppInfo4.MSFlexCrtInfo.ColWidth(0) = 800                       '
Width of AppNo
    frmNewAppInfo4.MSFlexCrtInfo.ColWidth(1) = 1100                      '
Width of Date
    frmNewAppInfo4.MSFlexCrtInfo.ColWidth(2) = 1500                      '
Width of Court
    frmNewAppInfo4.MSFlexCrtInfo.ColWidth(3) = 600                       '
Width of Room
    frmNewAppInfo4.MSFlexCrtInfo.ColWidth(4) = 1100                      '
Width of CrtTime
    frmNewAppInfo4.MSFlexCrtInfo.ColWidth(5) = 1500                      '
Width of CourtPending
    frmNewAppInfo4.MSFlexCrtInfo.ColWidth(6) = 800                       '
Width of Appeared
    frmNewAppInfo4.MSFlexCrtInfo.ColWidth(7) = 0                         '
CourtKey

    Rs7.MoveFirst
    frmNewAppInfo4.MSFlexCrtInfo.Rows = 2

    Do Until Rs7.EOF

        frmNewAppInfo4.MSFlexCrtInfo.Col = 0
        frmNewAppInfo4.MSFlexCrtInfo.Text = Rs7!AppNo
        frmNewAppInfo4.MSFlexCrtInfo.Col = 1
        frmNewAppInfo4.MSFlexCrtInfo.Text = Rs7!CrtDate
        frmNewAppInfo4.MSFlexCrtInfo.Col = 2
        frmNewAppInfo4.MSFlexCrtInfo.Text = Rs7!Court
        frmNewAppInfo4.MSFlexCrtInfo.Col = 3
        frmNewAppInfo4.MSFlexCrtInfo.Text = Rs7!Room
        frmNewAppInfo4.MSFlexCrtInfo.Col = 4
        frmNewAppInfo4.MSFlexCrtInfo.Text = Rs7!CrtTime
        frmNewAppInfo4.MSFlexCrtInfo.Col = 5
        frmNewAppInfo4.MSFlexCrtInfo.Text = Rs7!CourtPending
        frmNewAppInfo4.MSFlexCrtInfo.Col = 6
        frmNewAppInfo4.MSFlexCrtInfo.Text = Rs7!Appeared
        frmNewAppInfo4.MSFlexCrtInfo.Col = 7
        frmNewAppInfo4.MSFlexCrtInfo.Text = Rs7!CourtKey
        frmNewAppInfo4.MSFlexCrtInfo.Row = frmNewAppInfo4.MSFlexCrtInfo.Row
+ 1 'Add more rows (Change to next row)
        Rs7.MoveNext
        'frmNewAppInfo4.MSFlexCrtInfo.Refresh

    Loop
Else
    MsgBox AppMode
    If Rs7.EOF And Rs7.BOF Then MsgBox "There are entries in the Court
Information Table for application: " & AppNo, vbInformation + vbOKOnly,
App.Title

End If

Exit Sub

CourtListErr:
If Rs7.EOF Then Exit Sub

If Err.Number = 30009 And AppMode = 14 Then               'Out of rows
    frmNewAppInfo4.MSFlexCrtInfo.Rows = frmNewAppInfo4.MSFlexCrtInfo.Rows +
1 'Add more rows
    frmNewAppInfo4.MSFlexCrtInfo.Refresh
    Resume                                  'Continue
Else
    MsgBox "out of rows outside of the newapps functions"

End If

MsgBox Str(Err.Number) & " - " & Err.Description
Rs7.Close

End Sub



Mon, 13 Sep 2004 23:38:21 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. MSFlex grid and other controls license problems

2. BIG PROBLEM with MSFLEX GRID CONTROL - Help Needed

3. Problem using a MSFlex Grid in an Outllook Form

4. MSFlex Grid Problem!?

5. problem with MSFlex Grid

6. problem with MSFlex Grid

7. MSFlex Grid Control - Help please

8. MSFlex Grid control

9. How to edit the MSFLEX grid control?

10. MSFlex Grid

11. Sorting date's in MSFlex grid

12. Sorting date's in MSFlex grid

 

 
Powered by phpBB® Forum Software