Results 1 to 2 of 2

Thread: Requerying a MSHFlexgrid

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2000
    Location
    Sunderland, UK
    Posts
    1

    Angry

    When I am trying to add/edit/delete to a MSHflexgrid with the following code it will not update the database, unless I stop the program running and restart it. I would be grateful if anyone can see anything that is blatantly obvious with this code that would prevent the database to refresh correctly.


    Private Sub cmdToDoAdd_Click()
    With DataEnvironment1.rsComToDo
    .Close
    .Open "select * from todo", , adOpenDynamic
    .AddNew
    .Fields("ProjectID") = DataEnvironment1.rsComProjects.Fields("projectID")
    End With
    DataEnvironment1.rsComToDo.AddNew
    frmToDo.Show 1


    DataEnvironment1.rsComProjects.Requery
    Set myRS = DataEnvironment1.rsComProjects.Fields("comtodoview").Value


    End Sub

    _---------------------------------------------------------

    Private Sub cmdToDoDelete_Click()
    flxToDoItems.Col = 0
    tempval = "" & flxToDoItems.Text

    flxToDoItems.ColSel = 4
    If IsNumeric(tempval) Then
    With DataEnvironment1.rsComToDo
    .Close
    .Open "select * from todo where uniqueID = " & tempval

    If .RecordCount > 0 Then
    result = MsgBox("Are you sure you want to delete the item: " & DataEnvironment1.rsComToDo.Fields("itemname").Value, vbOKCancel, "delete")

    If result = 1 Then DataEnvironment1.rsComToDo.Delete

    DataEnvironment1.rsComProjects.Requery

    Set myRS = DataEnvironment1.rsComProjects.Fields("comtodoview").Value

    End If



    End With


    -----------------------------------------------------------

    Private Sub cmdToDoEdit_Click()
    flxToDoItems.Col = 0
    tempval = "" & flxToDoItems.Text

    flxToDoItems.ColSel = 4
    If IsNumeric(tempval) Then
    With DataEnvironment1.rsComToDo
    .Close
    .Open "select * from todo where uniqueID = " & tempval
    If .RecordCount > 0 Then
    frmToDo.Show 1
    End If
    End With
    End If

    End Sub

    ----------------------------------------------------------

    Many Thanks

  2. #2
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Dunmow,Essex,England
    Posts
    898

    Cool

    Hi,

    A couple of things to try:
    Sometimes with a flexgrid Requery also requires a rebind. Try adding rebind as well.

    Secondly You may also need to use the update method since for instance in your add new section your have a .addnew method with no coresponding update. This probably means that the data has been logically posted back to the database but not phsically posted. When you close the program it performs an explicit update this is more than likeky due to the Database setup since normally a rollback would occur.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width