FredixBlog


Just my log about anything I could find enjoyable.



Clear all line breaks

author Posted by: fredometro on date Jan 6th, 2004 | filed Filed under: MS-Access

Quertion: Can anyone figure out a little function that will clear all line breaks (Chr(10)+Chr(13)) in a string?
Matt(+)

Fredix gave this response on 1/17/2002:
Hi!

Here is a function I use:


Public Function ClearBreaks(TheString)
dim ch, result as string
dim i as integer

    result = ""
    if len(TheString) = 0 then
        ClearBreaks = ""
        exit function
    end if

    for i = 1 to len(TheString)
        ch = mid(TheString,i,1)
        if ch <> chr(13) and ch <> chr(10) then
            result = result & ch
        else
            if ch = chr(13) then result = result & " "
        end if
    next i

    ClearBreaks = result

end function

With this, you will have the line breaks replaced by a space.

Regards.

Copy a file

author Posted by: fredometro on date Jan 1st, 2004 | filed Filed under: MS-Access

This function copies a file


Const FOF_NOCONFIRMMKDIR = &H200
Const FOF_FILESONLY = &H80

Private Type SHFILEOPSTRUCT
      hwnd As Long
    wFunc As Long
    pFrom As String
    pTo As String
    fFlags As Integer
    fAborted As Boolean
    hNameMaps As Long
    sProgress As String
End Type

Private Declare Function SHFileOperation Lib "shell32.dll" _
    Alias "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long

Public Function MyFileCopy(txtSource, txtDestination)
Dim lFileOp As Long
Dim lresult As Long
Dim lFlags As Long
Dim SHFileOp As SHFILEOPSTRUCT
Dim chkSilent, chkYesToAll, chkRename, chkDir, chkFilesOnly As Boolean

DoCmd.Hourglass True

lFileOp = FO_COPY

chkYesToAll = True
chkSilent = True

If chkSilent Then lFlags = lFlags Or FOF_SILENT
If chkYesToAll Then lFlags = lFlags Or FOF_NOCONFIRMATION
If chkRename Then lFlags = lFlags Or FOF_RENAMEONCOLLISION
If chkDir Then lFlags = lFlags Or FOF_NOCONFIRMMKDIR
If chkFilesOnly Then lFlags = lFlags Or FOF_FILESONLY
'
' NOTE: By adding the FOF_ALLOWUNDO flag you can move
' a file to the Recycle Bin instead of deleting it.
'
With SHFileOp
    .wFunc = lFileOp
    .pFrom = txtSource & vbNullChar &amp; vbNullChar
    .pTo = txtDestination & vbNullChar &amp; vbNullChar
    .fFlags = lFlags
End With
lresult = SHFileOperation(SHFileOp)
'
' If User hit Cancel button while operation is in progress,
' the fAborted parameter will be true
'
DoCmd.Hourglass False
'If lresult <> 0 Or SHFileOp.fAborted Then Exit Function
'MsgBox "Operation Complete", vbInformation, "File Operations"
MyFileCopy = lresult
End Function

Replicate a database

author Posted by: fredometro on date Jan 1st, 2004 | filed Filed under: MS-Access

This function replicates a database with another replica, or the master database.
The databases are secured.


Public Function RunReplication(TheMaster, TheRemote, UserName, Password)
Dim db As Database
Dim myDBE As DBEngine
Dim dbMyNewMdb As Database
Dim ws As Workspace
On Error GoTo Err_RunReplication
Set myDBE = New PrivDBEngine
myDBE.SystemDB = DBEngine.SystemDB
myDBE.DefaultUser = UserName
myDBE.DefaultPassword = Password
Set ws = myDBE.CreateWorkspace("ws", UserName, Password)

Set dbMyNewMdb = ws.OpenDatabase(TheMaster)

RunReplication = True

On Error Resume Next

dbMyNewMdb.Synchronize TheRemote
If Err <> 0 Then
    MsgBox Error$
    RunReplication = False
End If

On Error GoTo Err_RunReplication
dbMyNewMdb.Close
Set dbMyNewMdb = Nothing
Exit Function
Err_RunReplication:
MsgBox Error$, vbCritical
RunReplication = False

End Function

AddReference()

author Posted by: fredometro on date Jan 1st, 2004 | filed Filed under: MS-Access

This function creates a reference to the specific library.


Function AddReference(chNomFichier As String) As Boolean
Dim ref As Reference

     On Error GoTo Erreur_AddReference
     Set ref = References.AddFromFile(chNomFichier)
     AddReference = True

    Sortie_AddReference:
     Exit Function

    Erreur_AddReference:
     MsgBox Err & ": " & Err.Description
     AddReference = False
     Resume Sortie_AddReference
End Function


Warning: include(/home/www/web421/html/phpTraffic/write_logs.php) [function.include]: failed to open stream: No such file or directory in /home/websitef/public_html/fredometro.com/wp-content/themes/blueshadow/footer.php on line 15

Warning: include() [function.include]: Failed opening '/home/www/web421/html/phpTraffic/write_logs.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/websitef/public_html/fredometro.com/wp-content/themes/blueshadow/footer.php on line 15