User Tools

Site Tools


software:microsoft:access

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
software:microsoft:access [2015/05/05 16:43] – created superwizardsoftware:microsoft:access [2021/10/11 00:32] (current) – [Can t find project or library] superwizard
Line 1: Line 1:
 +====== PtrSafe Access adjustment for 64 bit ======
 +
 +2020-02-26
 +
 +
 +Compile error 64-bit
 +
 +Change this
 +
 +    Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
 +    Private Declare Function GetExitCodeProcess Lib "kernel32" (ByVal hProcess As Long, lpExitCode As Long) As Long
 +
 +to this and it will compile on both 32-bit and 64-bit
 +
 +<code>
 +#If Win64 Then
 +    Private Declare PtrSafe Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
 +    Private Declare PtrSafe Function GetExitCodeProcess Lib "kernel32" (ByVal hProcess As Long, lpExitCode As Long) As Long
 +#Else
 +    Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
 +    Private Declare Function GetExitCodeProcess Lib "kernel32" (ByVal hProcess As Long, lpExitCode As Long) As Long
 +#End If
 +</code>
 +From <https://stackoverflow.com/questions/6255750/how-do-i-convert-this-program-to-work-on-a-64-bit-machine> 
 +
 +
 +2020-02-20
 +
 +Compile error
 +
 +
 + 
 +Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal _
 +    hHandle As Long, ByVal dwMilliseconds As Long) As Long
 +    
 +====== Can t find project or library ======
 +<WRAP center round box >
 +
 +
 +        dtFMSProcessingDate = Date
 +        
 +        
 +        MsgBox VBA.Date
 +
 +From <https://stackoverflow.com/questions/31575414/access-vba-date-function-not-working> 
 +
 +Also
 +
 +2021-10-09
 +
 +TRIM() not found? Compile error: Can't find project or library in Excel 2007
 +
 +From <https://social.msdn.microsoft.com/Forums/office/en-US/608c32c1-3d47-47f4-a6ff-893b4695db20/trim-not-found-compile-error-cant-find-project-or-library-in-excel-2007?forum=exceldev> 
 +
 + 
 +Answer: **On the VBA window go to Tools->References and uncheck the MISSING references.**
 +
 +    ClosedXML - Create Excel files in .Net
 + • Proposed as answer byTim Johnson at AptosFriday, June 6, 2014 5:13 PM
 + • Unproposed as answer byTim Johnson at AptosFriday, June 6, 2014 5:13 PM
 +    Thursday, January 20, 2011 4:54 AM
 +
 +From <https://social.msdn.microsoft.com/Forums/office/en-US/608c32c1-3d47-47f4-a6ff-893b4695db20/trim-not-found-compile-error-cant-find-project-or-library-in-excel-2007?forum=exceldev> 
 +
 +
 +</WRAP>
 +
 +
 +        
 +
 +====== How to display Access query results without having to create temporary query? ======
 +
 +
 +From: http://stackoverflow.com/questions/17328092/how-to-display-access-query-results-without-having-to-create-temporary-query
 +
 +<code>
 +Const cstrQueryName As String = "TemporaryQuery"
 +Dim db As DAO.Database
 +Dim qdf As DAO.QueryDef
 +Dim sqlStr As String
 +
 +'*Logic to create SQL query... variable to hold query is called sqlStr*
 +' Apparently you have that piece worked out.  I'll use a simple query ...
 +sqlStr = "SELECT * FROM Dual;"
 +
 +Set db = CurrentDb
 +If Not QueryExists(cstrQueryName) Then
 +    Set qdf = db.CreateQueryDef(cstrQueryName)
 +Else
 +    Set qdf = db.QueryDefs(cstrQueryName)
 +End If
 +qdf.sql = sqlStr
 +Set qdf = Nothing
 +Set db = Nothing
 +DoCmd.OpenQuery cstrQueryName
 +If you still want to later discard the saved query, do this ...
 +
 +If QueryExists(cstrQueryName) Then
 +    DoCmd.DeleteObject acQuery, cstrQueryName
 +End If
 +This is the helper function for the above code ...
 +
 +Public Function QueryExists(ByVal pName As String) As Boolean
 +    Dim db As DAO.Database
 +    Dim qdf As DAO.QueryDef
 +    Dim blnReturn As Boolean
 +    Dim strMsg As String
 +
 +On Error GoTo ErrorHandler
 +
 +    blnReturn = False ' make it explicit
 +    Set db = CurrentDb
 +    Set qdf = db.QueryDefs(pName)
 +    blnReturn = True
 +
 +ExitHere:
 +    Set qdf = Nothing
 +    Set db = Nothing
 +    QueryExists = blnReturn
 +    Exit Function
 +
 +ErrorHandler:
 +    Select Case Err.Number
 +    Case 3265 ' Item not found in this collection.
 +    Case Else
 +        strMsg = "Error " & Err.Number & " (" & Err.Description _
 +            & ") in procedure QueryExists"
 +        MsgBox strMsg
 +    End Select
 +    GoTo ExitHere
 +
 +End Function
 +</code>
 +
 +
 +====== SaveAsText() in Access to export all code ======
 +
 +From: http://stackoverflow.com/questions/187506/how-do-you-use-version-control-with-access-development
 +
 +<code>
 +script in VBScript, that uses the undocumented Application.SaveAsText() in Access to export all code, form, macro and report modules.
 +
 +Updated to use OpenAccessProject() if it sees a .adp extension, else use OpenCurrentDatabase()
 +
 +----------------------------------------------------------------------------------------------
 +' Usage:
 + CScript decompose.vbs <input file> <path>
 +
 +' Converts all modules, classes, forms and macros from an Access Project file (.adp) <input file> to
 +' text and saves the results in separate files to <path> Requires Microsoft Access.
 +'
 +
 +Option Explicit
 +
 +const acForm = 2
 +const acModule = 5
 +const acMacro = 4
 +const acReport = 3
 +
 +' BEGIN CODE
 +Dim fso
 +Set fso = CreateObject("Scripting.FileSystemObject")
 +
 +dim sADPFilename
 +If (WScript.Arguments.Count = 0) then
 +    MsgBox "Bitte den Dateinamen angeben!", vbExclamation, "Error"
 +    Wscript.Quit()
 +End if
 +sADPFilename = fso.GetAbsolutePathName(WScript.Arguments(0))
 +
 +Dim sExportpath
 +If (WScript.Arguments.Count = 1) then
 +    sExportpath = ""
 +else
 +    sExportpath = WScript.Arguments(1)
 +End If
 +
 +
 +exportModulesTxt sADPFilename, sExportpath
 +
 +If (Err <> 0) and (Err.Description <> NULL) Then
 +    MsgBox Err.Description, vbExclamation, "Error"
 +    Err.Clear
 +End If
 +
 +Function exportModulesTxt(sADPFilename, sExportpath)
 +    Dim myComponent
 +    Dim sModuleType
 +    Dim sTempname
 +    Dim sOutstring
 +
 +    dim myType, myName, myPath, sStubADPFilename
 +    myType = fso.GetExtensionName(sADPFilename)
 +    myName = fso.GetBaseName(sADPFilename)
 +    myPath = fso.GetParentFolderName(sADPFilename)
 +
 +    If (sExportpath = "") then
 +        sExportpath = myPath & "\Source\"
 +    End If
 +    sStubADPFilename = sExportpath & myName & "_stub." & myType
 +
 +    WScript.Echo "copy stub to " & sStubADPFilename & "..."
 +    On Error Resume Next
 +        fso.CreateFolder(sExportpath)
 +    On Error Goto 0
 +    fso.CopyFile sADPFilename, sStubADPFilename
 +
 +    WScript.Echo "starting Access..."
 +    Dim oApplication
 +    Set oApplication = CreateObject("Access.Application")
 +    WScript.Echo "opening " & sStubADPFilename & " ..."
 +    If (Right(sStubADPFilename,4) = ".adp") Then
 +        oApplication.OpenAccessProject sStubADPFilename
 +    Else
 +        oApplication.OpenCurrentDatabase sStubADPFilename
 +    End If
 +
 +    oApplication.Visible = false
 +
 +    dim dctDelete
 +    Set dctDelete = CreateObject("Scripting.Dictionary")
 +    WScript.Echo "exporting..."
 +    Dim myObj
 +    For Each myObj In oApplication.CurrentProject.AllForms
 +        WScript.Echo "  " & myObj.fullname
 +        oApplication.SaveAsText acForm, myObj.fullname, sExportpath & "\" & myObj.fullname & ".form"
 +        oApplication.DoCmd.Close acForm, myObj.fullname
 +        dctDelete.Add "FO" & myObj.fullname, acForm
 +    Next
 +    For Each myObj In oApplication.CurrentProject.AllModules
 +        WScript.Echo "  " & myObj.fullname
 +        oApplication.SaveAsText acModule, myObj.fullname, sExportpath & "\" & myObj.fullname & ".bas"
 +        dctDelete.Add "MO" & myObj.fullname, acModule
 +    Next
 +    For Each myObj In oApplication.CurrentProject.AllMacros
 +        WScript.Echo "  " & myObj.fullname
 +        oApplication.SaveAsText acMacro, myObj.fullname, sExportpath & "\" & myObj.fullname & ".mac"
 +        dctDelete.Add "MA" & myObj.fullname, acMacro
 +    Next
 +    For Each myObj In oApplication.CurrentProject.AllReports
 +        WScript.Echo "  " & myObj.fullname
 +        oApplication.SaveAsText acReport, myObj.fullname, sExportpath & "\" & myObj.fullname & ".report"
 +        dctDelete.Add "RE" & myObj.fullname, acReport
 +    Next
 +
 +    WScript.Echo "deleting..."
 +    dim sObjectname
 +    For Each sObjectname In dctDelete
 +        WScript.Echo "  " & Mid(sObjectname, 3)
 +        oApplication.DoCmd.DeleteObject dctDelete(sObjectname), Mid(sObjectname, 3)
 +    Next
 +
 +    oApplication.CloseCurrentDatabase
 +    oApplication.CompactRepair sStubADPFilename, sStubADPFilename & "_"
 +    oApplication.Quit
 +
 +    fso.CopyFile sStubADPFilename & "_", sStubADPFilename
 +    fso.DeleteFile sStubADPFilename & "_"
 +
 +
 +End Function
 +
 +Public Function getErr()
 +    Dim strError
 +    strError = vbCrLf & "----------------------------------------------------------------------------------------------------------------------------------------" & vbCrLf & _
 +               "From " & Err.source & ":" & vbCrLf & _
 +               "    Description: " & Err.Description & vbCrLf & _
 +               "    Code: " & Err.Number & vbCrLf
 +    getErr = strError
 +End Function
 +</code>
 +
 ====== Replacing the Calendar Control in Access 2010 Applications ====== ====== Replacing the Calendar Control in Access 2010 Applications ======
  
Line 60: Line 332:
 From: http://community.spiceworks.com/how_to/show/5517-how-to-solve-missing-mscal-ocx-reference-in-microsoft-access-2010 From: http://community.spiceworks.com/how_to/show/5517-how-to-solve-missing-mscal-ocx-reference-in-microsoft-access-2010
  
-    However note, that the solution specified is a work-around for the above problem. Microsoft has stated that the Calendar control feature is deprecated in Access 2010 and has suggested a number of options for replacing it. See the link referenced at the bottom of this page for more details+From: https://social.msdn.microsoft.com/Forums/office/en-US/fd1d449e-d39c-4c0b-99ea-ed561d8906ce/mscalocx-microsoft-calendar-control-conversion-to-mscomct2ocx?forum=exceldev 
 + 
 +    However note, that the solution specified is a work-around for the above problem. Microsoft has stated  
 +    that the Calendar control feature is deprecated in Access 2010 and has suggested a number of options  
 +    for replacing it. See the link referenced at the bottom of this page for more details
          
     Centerport     Centerport
-    +   
 +   
 +    I. Click on the Windows Start menu and select 'Run'  
 +    II. In the Run command window enter: 
 +       regsvr32 %SystemRoot%\syswow64\mscal.ocx  
 +    III. Select OK to execute the command  
 ====== Forms: Date Picker without ActiveX ====== ====== Forms: Date Picker without ActiveX ======
  
software/microsoft/access.1430844237.txt.gz · Last modified: 2015/05/05 16:43 by superwizard