Results 1 to 7 of 7
  1. #1
    Join Date
    Aug 2011
    Posts
    12

    ODBC Error 3146 on rs.update

    Hi,
    Using MS Access, I have a form that is based on a table called Motion_Imagery. In the VBA of this code I want to take two fields on the form and add the data in those two fields to the last record that was added to table Online_Books. When I run my code I get the error when it gets to rs.update, here is my code:


    Set db = CurrentDb()
    Set rs = db.OpenRecordset("dbo_Filestream_Files", dbOpenDynaset, dbSeeChanges)



    rs.MoveLast

    rs.Edit
    rs![Prefix_CTRL_NBR] = Me.Prefix_CTRL_NBR
    rs![CTRL_ID] = Me.CTRL_NBR
    rs.Update

    Can you tell me what the problem is? Is this possible to do?

    Thanks,
    Sharon

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,530
    What is error 3146? I'd point out that the table in your code isn't either of the ones mentioned. I would not count on MoveLast to find the right record (though it might). It's also inefficient to open the whole table. I'd open the recordset on an SQL statement that returned the specific record I wanted to update.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Join Date
    Aug 2011
    Posts
    12

    ODBC Error 3146 on rs.update

    Quote Originally Posted by pbaldy View Post
    What is error 3146? I'd point out that the table in your code isn't either of the ones mentioned. I would not count on MoveLast to find the right record (though it might). It's also inefficient to open the whole table. I'd open the recordset on an SQL statement that returned the specific record I wanted to update.
    Sorry, you are correct. Instead of Online_Books I should have said dbo_Filestream_File for table 2. I don't know what the odbc error 3146 means.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,972
    Why do you need to save this data to another record? Why was record created without it? Assuming the last record in table is the record you want to edit is risky. Are there multiple users?

    I can't get that code syntax to work. But these do:
    Code:
    Dim cn As ADODB.Connection
    Dim rs As ADODB.Recordset
    Set cn = CurrentProject.Connection
    Set rs = New ADODB.Recordset
    rs.Open "SELECT * FROM dbo_Filestream_File;", cn, adOpenDynamic, adLockPessimistic
    rs.MoveLast
    rs![Prefix_CTRL_NBR] = Me.Prefix_CTRL_NBR
    rs![CTRL_ID] = Me.CTRL_NBR
    rs.Update
    Code:
    Dim db As DAO.Database
    Dim rs As DAO.Recordset
    Set db = CurrentDb
    Set rs = db.OpenRecordset("dbo_Filestream_File", dbOpenDynaset, dbSeeChanges)
    rs.MoveLast
    rs.Edit
    rs![Prefix_CTRL_NBR] = Me.Prefix_CTRL_NBR
    rs![CTRL_ID] = Me.CTRL_NBR
    rs.Update
    Either explicitely declaring the DAO was key or leaving the parens off CurrentDb in the second procedure.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    Join Date
    Aug 2011
    Posts
    12

    ODBC error 3146 on rs.update

    Thank you. I will give this code a try.

    Sharon

    Quote Originally Posted by June7 View Post
    Why do you need to save this data to another record? Why was record created without it? Assuming the last record in table is the record you want to edit is risky. Are there multiple users?

    I can't get that code syntax to work. But these do:
    Code:
    Dim cn As ADODB.Connection
    Dim rs As ADODB.Recordset
    Set cn = CurrentProject.Connection
    Set rs = New ADODB.Recordset
    rs.Open "SELECT * FROM dbo_Filestream_File;", cn, adOpenDynamic, adLockPessimistic
    rs.MoveLast
    rs![Prefix_CTRL_NBR] = Me.Prefix_CTRL_NBR
    rs![CTRL_ID] = Me.CTRL_NBR
    rs.Update
    Code:
    Dim db As DAO.Database
    Dim rs As DAO.Recordset
    Set db = CurrentDb
    Set rs = db.OpenRecordset("dbo_Filestream_File", dbOpenDynaset, dbSeeChanges)
    rs.MoveLast
    rs.Edit
    rs![Prefix_CTRL_NBR] = Me.Prefix_CTRL_NBR
    rs![CTRL_ID] = Me.CTRL_NBR
    rs.Update
    Either explicitely declaring the DAO was key or leaving the parens off CurrentDb in the second procedure.

  6. #6
    Join Date
    Aug 2011
    Posts
    12
    In the filestream_File table I have a picture stored that goes with a record in the table called Motion_Imagery. I need to have some way of matching these two records up for reports. The Primary key for the Filestream_file table is fID. The Primary key for the Motion_Imagery table is Prefix_CTRL_NBR and CTRL_ID. By putting the two fields Prefix_CTRL_NBR and CTRL_ID in the Filestream_File table, I am then able to select a record from the filestream_File table that connects to the Motion_Table record.

    Sharon

  7. #7
    Join Date
    Aug 2011
    Posts
    12
    thank you all. I have decided to try a different approach.

    Sharon

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

Similar Threads

  1. ODBC -- Call Failed error
    By Coffee in forum Access
    Replies: 3
    Last Post: 07-08-2011, 10:34 AM
  2. Odbc error please help
    By TCB in forum Access
    Replies: 3
    Last Post: 04-13-2011, 02:07 PM
  3. ODBC 32 to 64 Bit connection error
    By mgmtexecit in forum Reports
    Replies: 0
    Last Post: 03-30-2011, 10:06 AM
  4. ODBC 32 to 64 Bit connection error
    By mgmtexecit in forum Access
    Replies: 1
    Last Post: 03-30-2011, 10:05 AM
  5. Replies: 0
    Last Post: 11-30-2010, 12:23 PM

Tags for this Thread

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