Results 1 to 13 of 13
  1. #1
    fluffyvampirekitten is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Jun 2015
    Posts
    108

    Call function is not executed

    At first my " Call Update_ProdSAP " is working until i added this few lines


    Code:
    UpdateReqProdSAPSQL = "UPDATE PROD_SAP " & _
                "SET PAT_NAME = PAT_LASTNAME & PAT_FIRSTNAME "
            DoCmd.RunSQL UpdateReqProdSAPSQL
    For some reasons , the update can work but the call method is not executed.
    Any ideas where went wrong ?
    Thanks in a advance .




    Code:
    Private Sub cmd_YesProdSAP_Click()
    Dim fDialog    As Object
    Dim SourcePath As String
    Dim Success As Boolean
    Dim DelReqProdSAPSQL As String
    Dim LoadReqProdSAPSQL As String
    Dim UpdateReqProdSAPSQL As String
    
    On Error GoTo ErrorHandler
        
        Set fDialog = Application.FileDialog(3)
        Dim varFile As Variant
        Success = False
        With fDialog
           .AllowMultiSelect = False
           .Title = "Select excel file to import the data :"
           .InitialFileName = "c:\"
            If .Show = True Then
               For Each varFile In .SelectedItems
                 SourcePath = varFile
               Next
               Success = True
            Else
               Success = False
            End If
        End With
        
        If Success Then
            
        
            DelReqProdSAPSQL = "Delete * From Prod_SAP"
            DoCmd.RunSQL DelReqProdSAPSQL
            DoCmd.TransferSpreadsheet acImport, 8, "Prod_SAP", SourcePath, True, ""
                                    
            Call Update_ProdSAP
            
            UpdateReqProdSAPSQL = "UPDATE PROD_SAP " & _
                "SET PAT_NAME = PAT_LASTNAME & PAT_FIRSTNAME "
            DoCmd.RunSQL UpdateReqProdSAPSQL
            
            
                                                               
        End If
        
        
    ErrorHandlerExit:
        Exit Sub
        
    ErrorHandler:
       MsgBox "Please import the correct file!"
        Me.Refresh
    Resume ErrorHandlerExit
    End Sub

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    You say that Update_ProdSAP used to work and now it does not? Perhaps executing UpdateReqProdSAPSQL is changing the updates made by the function.

  3. #3
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Why are you saving concatenated value anyway? This can be calculated when needed.
    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.

  4. #4
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    At first my " Call Update_ProdSAP " is working until i added this few lines
    You would have to single step through the code to determine if the Call is being executed.


    I would change the code to
    Code:
            UpdateReqProdSAPSQL = "UPDATE PROD_SAP " & _
                                  "SET PAT_NAME = PAT_LASTNAME & PAT_FIRSTNAME "
            Debug.Print UpdateReqProdSAPSQL
    
            'DoCmd.RunSQL UpdateReqProdSAPSQL
            CurrentDb.Execute UpdateReqProdSAPSQL, dbFailOnError  '<-- My preference
    The debug line allows you to see if the SQL statement is correctly formed. Comment out the line after debugging.
    I don't thing the SQL is formed correctly.

    The "DoCmd.RunSQL" executes the SQL through Access and "CurrentDb.Execute" executes the SQL through the dB engine, either Jet (pre A2007) or ACE (A2007 and later)
    (Microsoft JET stands for Joint Engine Technology)
    (with version 2007 onwards, JET was replaced with what was initially called the Office Access Connectivity Engine (ACE), but which is now called the Access Database Engine)

  5. #5
    fluffyvampirekitten is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Jun 2015
    Posts
    108
    Quote Originally Posted by June7 View Post
    Why are you saving concatenated value anyway? This can be calculated when needed.

    I have 2 fields in my table : PAT_LASTNAME & PAT_FIRSTNAME (tbl: PROD_SAP)
    I wanna combine these two fields into one field: PAT_NAME (this column is in the same table as well - tbl: PROD_SAP)

    tbl: PROD_SAP have around 800 000 rows.

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Again, why bother saving concatenated data? This can be calculated when needed.
    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.

  7. #7
    fluffyvampirekitten is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Jun 2015
    Posts
    108
    Quote Originally Posted by June7 View Post
    Again, why bother saving concatenated data? This can be calculated when needed.
    I need to use the field "PAT_NAME" to union with another table and find duplicates.

  8. #8
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    That can be done with query. Still don't see need to save the calculated value.

    You say union, did you mean join?
    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.

  9. #9
    fluffyvampirekitten is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Jun 2015
    Posts
    108
    Quote Originally Posted by ssanfu View Post
    You would have to single step through the code to determine if the Call is being executed.


    I would change the code to
    Code:
            UpdateReqProdSAPSQL = "UPDATE PROD_SAP " & _
                                  "SET PAT_NAME = PAT_LASTNAME & PAT_FIRSTNAME "
            Debug.Print UpdateReqProdSAPSQL
    
            'DoCmd.RunSQL UpdateReqProdSAPSQL
            CurrentDb.Execute UpdateReqProdSAPSQL, dbFailOnError  '<-- My preference
    The debug line allows you to see if the SQL statement is correctly formed. Comment out the line after debugging.
    I don't thing the SQL is formed correctly.

    The "DoCmd.RunSQL" executes the SQL through Access and "CurrentDb.Execute" executes the SQL through the dB engine, either Jet (pre A2007) or ACE (A2007 and later)
    (Microsoft JET stands for Joint Engine Technology)
    (with version 2007 onwards, JET was replaced with what was initially called the Office Access Connectivity Engine (ACE), but which is now called the Access Database Engine)

    Thanks for the help and tips

    This UpdateReqProdSAPSQL can work fine.

    Still, my Call function is not executed.

  10. #10
    fluffyvampirekitten is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Jun 2015
    Posts
    108
    Quote Originally Posted by June7 View Post
    That can be done with query. Still don't see need to save the calculated value.

    You say union, did you mean join?
    If i create a query , it will create another table right ? Then , I might encounter this error " There isn't enough disk space or memory to undo the data changes this action query is about to make "

    I mean "Union ALL" .

  11. #11
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    A SELECT query does not create a table and therefore no, should not get that error.
    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.

  12. #12
    fluffyvampirekitten is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Jun 2015
    Posts
    108
    Quote Originally Posted by June7 View Post
    A SELECT query does not create a table and therefore no, should not get that error.

    I will try to create a query . Do i need this statement CurrentDb.OpenRecordset("yourQueryName") to run my query ?
    Kindly advise . Thank you.

  13. #13
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    SELECT queries are not 'run' - only action queries (DELETE, UPDATE, INSERT) are run. SELECT queries are used like tables. They can be opened or used as source for forms and reports.

    This is basic Access functionality. Your profile describes yourself as 'Advanced Beginner' - are you not already familiar with using SELECT queries?
    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.

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

Similar Threads

  1. call class function from object
    By Ruegen in forum Programming
    Replies: 2
    Last Post: 01-20-2015, 09:51 AM
  2. can't trace function call
    By visions in forum Programming
    Replies: 14
    Last Post: 12-28-2014, 01:24 PM
  3. Function call in query slowing it down
    By sneuberg in forum Queries
    Replies: 2
    Last Post: 10-17-2014, 10:32 AM
  4. Call A function
    By aspen in forum Programming
    Replies: 10
    Last Post: 03-16-2014, 12:57 PM
  5. Replies: 1
    Last Post: 07-16-2012, 03:10 PM

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