Page 3 of 3 FirstFirst 123
Results 31 to 41 of 41
  1. #31
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,550
    Forum working fine for me?


    You can mark the thread solved then? Top right of thread, Thread tools.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  2. #32
    roberto21 is offline Advanced Beginner
    Windows 11 Access 2021
    Join Date
    Apr 2019
    Posts
    89
    I have no doubt that the forum is working fine for you. It's me that is kicked out (three times this time) Now I write the post in Notepad, and then copy it as fast as I can, before getting kicked out. OK, no problem.
    The thread is closed. Beware; with sql9.3 you MUST use dbSeeChanges. If you use dbFailOnError you will get the error. Is that correct that you cannot use more than one option in database.execute statement? Microsoft is not clear on this point, and writes "db.excute query, optionS" (plural).

  3. #33
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,550
    It's me that is kicked out (three times this time)
    The first thing I would do in that case then, is try another browser.

    I use Chrome mainly.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  4. #34
    Minty is offline VIP
    Windows 11 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,157
    Quote Originally Posted by roberto21 View Post
    I have no doubt that the forum is working fine for you. It's me that is kicked out (three times this time) Now I write the post in Notepad, and then copy it as fast as I can, before getting kicked out. OK, no problem.
    The thread is closed. Beware; with sql9.3 you MUST use dbSeeChanges. If you use dbFailOnError you will get the error. Is that correct that you cannot use more than one option in database.execute statement? Microsoft is not clear on this point, and writes "db.excute query, optionS" (plural).
    The correct way to use both :

    db.Execute strSQL, dbFailOnError + dbSeeChanges

    They are bitwise options so adding them together Access know to use both.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  5. #35
    roberto21 is offline Advanced Beginner
    Windows 11 Access 2021
    Join Date
    Apr 2019
    Posts
    89
    Thank you for the info. You are right, using that way you don't get the compile error. However, writing

    db.Execute strSQL, dbFailOnError + dbSeeChanges
    or
    db.Execute strSQL, dbSeeChanges + dbFailOnError

    causes the dreaded error (access blocked etc etc). Using only dbSeeChanges works fine. I am not sure I understand what is going on here, because if the error is in the lack of dbSeeChanges the previous statements should work. Any ideas?

  6. #36
    roberto21 is offline Advanced Beginner
    Windows 11 Access 2021
    Join Date
    Apr 2019
    Posts
    89
    I don't know if someone is still interested in the matter, but here there are two more pieces in the puzzle.
    1) using the Recordset technique (see my first post) does not work in any case. Even removing dbFailOnError and leaving dbSeeChanges, the error pops out anyhow.
    2) the following technique (execute querydef) works OK even with dbFailOnError

    Code:
    Private Sub AggiornaLibroSoci(NTes As Integer, nDate As Date)
        Dim dbs As DAO.Database
        Dim rstLibroSoci As DAO.Recordset
        Dim strSql As String
        Dim nYear As Integer
        Dim qdefUpdate As QueryDef
            
        nYear = Year(Date)
        If Month(nDate) > 8 Then
            nYear = nYear + 1
        End If
        
        Set dbs = CurrentDb
       
        If Me.Nuova_TessElett <> "" Then
            strSql = "Update LibroSoci Set [Quota associativa] = " & nYear & _
                ", [Tessera Elettronica] = " & Me.Nuova_TessElett & " WHERE [Numero Tessera] = " & NTes
        Else
            strSql = "Update LibroSoci Set [Quota associativa] = " & nYear & " WHERE [Numero Tessera] = " & NTes
        End If
        
        Set qdefUpdate = dbs.CreateQueryDef("", strSql)
    
    
        qdefUpdate.Execute dbFailOnError
    
    
    
        Set dbs = Nothing

  7. #37
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2013 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,250
    I did ask you what options do you use in your connection string but you never answered; it might be that your connection is not set up properly for use with and Access front-end. I am no MySQL expert but many years ago when I was heavily involved with Access db development there were some options you needed to use in your ODBC driver (I believe at the time I was using 5.1) for the MySQL back-end to work with the Access front-end.
    Here is an example of what I mean, this is from the msysObjects system table's Connect field for the linked MySQL table:
    DRIVER={MySQL ODBC 5.1 Driver};SERVER=MyServer;DATABASE=MyDB;PORT=3306;UI D=JohnDoe;PWD=SecretPW;Option=4194314

    Here is a page I found with some more info:
    https://dev.mysql.com/doc/connector-...n-option-flags

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  8. #38
    roberto21 is offline Advanced Beginner
    Windows 11 Access 2021
    Join Date
    Apr 2019
    Posts
    89
    Sorry for the missed answer. The connection string I use

    DRIVER={MySQL ODBC 9.4 Unicode Driver};UID=root;PWD=rootpwd;DATABASE=nuovodbricev utemysql; DFLT_BIGINT_BIND_STR=1;NO_SCHEMA=1;PORT=3306;SERVE R=localhost;ACCDB=YES;

    I have no idea about the OPTION parameter. You think is important (boldface), but really I don't know what to make of it. Tried to read the documentation, but it is still unclear. I plead guilty of ignorance

  9. #39
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2013 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,250
    I would at least add the two options\parameters (FOUND_ROWS=1;DYNAMIC_CURSOR=1) as suggested in the link I've sent you:
    Click image for larger version. 

Name:	Screenshot 2025-07-27 084137.png 
Views:	18 
Size:	167.5 KB 
ID:	53163
    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  10. #40
    roberto21 is offline Advanced Beginner
    Windows 11 Access 2021
    Join Date
    Apr 2019
    Posts
    89
    Thank you very much for your suggestions. I ran a few tests adding those parameters to the connection string, that now reads


    DRIVER={MySQL ODBC 9.4 Unicode Driver};UID=root;PWD=mysql1023root;DATABASE=nuovod bricevutemysql;DFLT_BIGINT_BIND_STR=1;NO_SCHEMA=1; PORT=3306;SERVER=localhost;ACCDB=YES;FOUND_ROWS=1; DYNAMIC_CURSOR=1;


    asnd indeed something changed. Now the ,execute technique works also adding dbFailOnError


    Code:
    With dbs
            .Execute strSql, dbSeeChanges + dbFailOnError
            MsgBox .RecordsAffected & " LibroSoci record(s) updated"
     End With
    and also the technique with the recordset now works, even though it does not accept the dbFailOnError (according to Ms, it should: is included in the optionEnum list, but maybe I misinterpreted)
    Click image for larger version. 

Name:	Untitled1 Copy.jpg 
Views:	11 
Size:	60.8 KB 
ID:	53165


    Code:
     Set rstLibroSoci = dbs.OpenRecordset(strSql, dbOpenDynaset, dbSeeChanges)
    
    
        rstLibroSoci.Edit
    
    
            rstLibroSoci![Quota associativa] = nYear
            If Me.Nuova_TessElett <> "" Then rstLibroSoci![Tessera Elettronica] = Me.Nuova_TessElett
    
    
    
    
       rstLibroSoci.Update
    Thanks again for your time and patience. There is really a lot to learn and understand.

  11. #41
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2013 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,250
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

Page 3 of 3 FirstFirst 123
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 16
    Last Post: 04-02-2020, 04:49 PM
  2. Inserting Data to Access Table (Local) from MySQL table (Net)
    By gambit1430 in forum Import/Export Data
    Replies: 2
    Last Post: 09-26-2014, 01:34 AM
  3. Replies: 7
    Last Post: 03-02-2014, 08:47 PM
  4. Replies: 5
    Last Post: 05-16-2012, 12:48 AM
  5. mySQL statement not updating table!!
    By Ran in forum SQL Server
    Replies: 3
    Last Post: 01-10-2012, 11:48 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