Results 1 to 2 of 2
  1. #1
    ddd is offline Novice
    Windows XP Access 2000
    Join Date
    Dec 2009
    Location
    Italy
    Posts
    6

    Wrong reference with .fields in DAO recordset

    Hi all,
    have been programming in Access for many years and yesterday something that left me puzzled happened.
    Am running a FE / BE database application on MSAccess 2000 (nope, am not upgrading ). One backend and about 3 FE running (some others are temporarily added for short times).

    Am using DAO recordsets to write and read emails text that will later be used to send data updates. Records are opened and then single fields are assigned or read from.
    Example:
    Code:
    Dim rst As Recordset
    ..
    Set dbs = CurrentDb
    Set rst = dbs.OpenRecordset("clients", dbOpenDynaset)
    ..
    For Each OlMail In OlItems
    ..
    rst.AddNew
    ..
    'gets the text after 'fieldname1:' and returns a string
    rst.Fields![fieldname1] = getValStr(textmsg, "fieldname1:")  
    ..
    It worked well for months. Yesterday, for unknown reason, the .fields! method instead of writing the value in fieldname1 tried to write it in fieldnameK.
    This was quite clear as (sheer luck) the fieldnameK field happened to be very short, not long enough to be assigned the returned string and thus causing an error. Plus its default value was 'IT' and that showed up when i monitored the values in debugging.
    Quite puzzled about HOW that happened (messed up pointers in Access?) I tried to recompile the module and voilà. Everything went back to normal.
    This morning the same problem happened with a read operation (reading from fieldnameK instead of fieldname1) and messed up data.
    As the other FE were working fine I just copied one of them on the offending machine and everything worked smoothly.

    While I keep the 'messed up' FE for investigations am quite puzzled about what happened. And worried. What if a wrong field was addressed and the error was not immediately showing?

    So my question (sorry for long post) is: has something like this occurred to you? do you have suggestions about what may be the cause?
    If it may help the database is quite big (about 200 MB of BE data) and the particular table has many fields (about 40, wouldnt be productive to separate them) but not so many records (about 5000).

    It seems an issue of bad pointer but what is causing it?

    Regards

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows XP Access 2002
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    You could easily have some form of corruption that could be impossible to pin down. I would try importing your db into a fresh, empty db and see if the problem persists. If not then just chalk it up to corruption. BTW, disambiguating your libraries might also help:
    Dim rst As DAO.Recordset

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 11-13-2009, 03:03 AM
  2. What's wrong with this expression
    By tallroger in forum Access
    Replies: 1
    Last Post: 05-05-2009, 04:00 PM
  3. What am I doing wrong?
    By brandon in forum Access
    Replies: 2
    Last Post: 08-03-2008, 10:26 AM
  4. Form Name Reference in VBA
    By Simon Sweet in forum Programming
    Replies: 0
    Last Post: 05-22-2008, 01:55 PM
  5. How to add Opensource reference???
    By loui in forum Access
    Replies: 0
    Last Post: 10-04-2007, 04:24 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums