Results 1 to 6 of 6

Thread: Vb6 Dao

  1. #1
    Join Date
    May 2006
    Posts
    4

    Unanswered: Vb6 Dao

    Hi, I hope I'm in the right place. I did alot of searching and could not find an answer so I will ask it here. I am trying to write a small app using DAO with an Access db. I will open the db and write a record. I set the '.Bookmark = .LastUpdated' assuming that a flag is created so that the next time I open the db it will be at the location of the last db change (I hope I understand that correctly, if not please let me know). I then call another function that opens the db and updates the same record, hopefully. The problem is that the first pass throught the 'update function' only creates a new redundant record instead of overwriting it. The second or more passes overwrites the second instance of the record correctly. Then I have to manually delete the original record. I just want a means to modify the last record that I have created. Here is some of my code:

    Function MyReportUpdate()
    Set MyDatabase = OpenDatabase(DataLocation, dbOpenTable)
    Set MyTable = MyDatabase.OpenRecordset("Reports", dbOpenTable)

    With MyTable
    .Edit

    !PtName = txtName.Text
    !DOB = MaskedDOB.Text
    !Sex = cboSex.Text

    .Update
    .Bookmark = .LastUpdated

    End With
    MyTable.Close
    MyDatabase.Close

    End Function




    Function MyReportSave
    Set MyDatabase = OpenDatabase(DataLocation, dbOpenTable)
    Set MyTable = MyDatabase.OpenRecordset("Reports", dbOpenTable)

    With MyTable

    .AddNew
    !PtName = txtName.Text
    !DOB = MaskedDOB.Text
    !Sex = cboSex.Text

    .Update
    .Bookmark = .LastUpdated

    End With
    MyTable.Close
    MyDatabase.Close

    End Function


    I want to call the 'MyReportSave' function, save a record, then call the 'MyReportUpdate' and update any changes that have occured.

    TIA

  2. #2
    Join Date
    May 2006
    Location
    Eagan, MN , USA
    Posts
    3

    Answer for your questions ..

    Hi PDMS,

    You hope too much .. see your write up .. kidding

    Well .. I guess problem can be that you are not using same instance of objects over which you are performing operations and setting properties.

    Just wanna confirm .. you are at right place. Feel safe and relaxed.

    Thanks & regards,
    Prasad

  3. #3
    Join Date
    May 2006
    Posts
    4
    Now I'm confused! : >, as if I was not before. How is it not the same instance? I have been trying to use the .bookmark to set the record location, But am not sure that I'm using it correctly.

  4. #4
    Join Date
    May 2006
    Location
    Eagan, MN , USA
    Posts
    3

    This is what I meant.

    With best regards,
    Prasad
    Attached Thumbnails Attached Thumbnails temp.GIF  

  5. #5
    Join Date
    May 2006
    Posts
    4
    We this is what I have come up with so far.

    1. Microsoft says there is a problem with DAO 3.6 and the Update command, they suggest usinh DAO 3.51. ( there might be a fix but I have not found it yet)

    2. DAO 3.51 will not work with a Access 2003 .mdb convert back to Access 97.

    3. The .LastUpdate command still seem to produce funky results. I achnged to .LastModified and it seems to work correctly now.

    This is a clip of the code that now seems to work. If there is something wrong with the code or I am missing something still, please let me know. Also, thaks Prasad for the info. I still don't get it, but will keep staring at the picture to see if I can get an epiphany.

    code clip:

    General Declaration

    Dim varRecordToReturnTo as variant




    Function MyReportUpdate()
    Set MyDatabase = OpenDatabase(DataLocation, dbOpenTable)
    Set MyTable = MyDatabase.OpenRecordset("Reports", dbOpenTable)

    With MyTable
    .Bookmark = varRecordToReturnTo
    .Edit

    !PtName = txtName.Text
    !DOB = MaskedDOB.Text
    !Sex = cboSex.Text

    .Update
    varRecordToReturnTo = .LastModified

    End With
    MyTable.Close
    MyDatabase.Close

    End Function




    Function MyReportSave
    Set MyDatabase = OpenDatabase(DataLocation, dbOpenTable)
    Set MyTable = MyDatabase.OpenRecordset("Reports", dbOpenTable)

    With MyTable

    .AddNew
    !PtName = txtName.Text
    !DOB = MaskedDOB.Text
    !Sex = cboSex.Text

    .Update
    varRecordToReturnTo = .LastModified

    End With
    MyTable.Close
    MyDatabase.Close

    End Function

  6. #6
    Join Date
    May 2006
    Posts
    4
    I was wrong the proplem was not with the Update method it is with the bookmarks.

    In DAO 3.60 using the Bookmark property of a recordset to navigate to a specific record places you on the wrong record. This is likely to surface when saving a Bookmark and moving to a different record, and then moving back to the bookmarked record by setting the Bookmark property of the recordset. This can also occur when using the LastModified property after an Update. This problem is most likely to happen if the table has a very large number of records, or if the table has fewer records but a very large number of columns.

    This does not occur when using DAO 3.51. They say to fix it update your DAO3.60 to a dll of this date or later.

    7/14/99 3.60.2927.4 545KB dao360.dll

    Mine appears to be newer than this file, but I am still having the problem discribed above. Does anyone know the fix for this, I would like to 3.6 instead of 3.51.

Posting Permissions

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