FredixBlog


Just my log about anything I could find enjoyable.



Gibson plus solide que Fender?

author Posted by: admin on date Feb 10th, 2009 | filed Filed under: Music

Ou Blackmore plus costaud que Cobain?

http://www.youtube.com/watch?v=c1mjx7eZcB4&NR=1

http://www.youtube.com/watch?v=Tdvi4Bj4uek&feature=related

P’têt que c’est une question d’habitude, mais le Kurt, il arrive qu’à péter la tête vous admettrez que c’est pas un exploit pour une LP.  :D :D

En tout cas une chose est sûre, Malmsteen y fait pas semblant, mais il mange beaucoup plus de frites.

http://www.youtube.com/watch?v=oXVmxqrMCIo&feature=related

Display a counter and remaining time in a loop

author Posted by: fredometro on date May 25th, 2007 | filed Filed under: MS-Access

When browsing thru records, a while/wend loop can take a long time to execute, depending on the number of records, communication speed and complexity of the process.

Here is a snippet that displays a counter, including estimated remaining time. After a few records browsed thru the loop, a rather accurate estimate of the remaining time can be displayed.


' Declarations
Dim starttime
Dim elapsedtime
Dim estimatedtime
Dim count
Dim counttot
Dim estHours, estMinutes, estSeconds

' Initializations: Code to be pasted BEFORE the while/wend loop
count = 0
counttot = ... 'whichever way you could get the number of records to be processed: DCOUNT, VIEW,    
                'rs.RecordCount...
starttime = Now()

' Displaying the count: Code to be pasted at the end of the loop, when jumping to the next record
    count = count + 1
    elapsedtime = DateDiff("s", starttime, Now())
    estimatedtime = elapsedtime / (count + 0.00001) ' time for one record
    estimatedtime = estimatedtime * (counttot - count) ' time for remaining records

    estHours = Int(estimatedtime / 3600)
    estMinutes = Int((estimatedtime - 3600 * estHours) / 60)
    estSeconds = Int(estimatedtime - (60 * estMinutes))
    If count / 100 = Int(count / 100) Then Echo True, "Uploading " & SourceTable & " on " & Get_rawmeasuresDb(CurrentDb.Name) & " : " & count & "/" & counttot & " records processed " & " Remaining: " & Format(TimeSerial(estHours, estMinutes, estSeconds), "hh:mm:ss")

Truncate long path names

author Posted by: fredometro on date May 25th, 2007 | filed Filed under: MS-Access

This function is useful when displaying or logging long path names.

Too long path names are annoying in a log file, because they are very often the same. Truncating the path to show only the beginning and the end helps readability.


Public Function TruncatedPath(TheText)
Dim pos1 As Integer
Dim pos2 As Integer
Dim ch As String
Dim i As Integer

pos1 = InStr(3, TheText, "\")
i = Len(TheText)
ch = Mid(TheText, i, 1)
While ch <> "\"
    i = i - 1
    ch = Mid(TheText, i, 1)
Wend
pos2 = Len(TheText) - i + 1

TruncatedPath = Left(TheText, pos1) & "..." & Right(TheText, pos2)
End Function

 

How can I e-mail a file from Microsoft Access?

author Posted by: fredometro on date Apr 22nd, 2004 | filed Filed under: MS-Access

Hello Anna!

Thanks to ask your question at my website. I am pleased to answer to your question:

How can I e-mail a file from Microsoft Access to other people?

Here is a simple function which sends an email with an attachment.


Public Function MailWithAttachment(Recipient as String, Subject as String, Body as String, Attachment as String)
' Start Outlook.
' If it is already running, you'll use the same instance...
Dim olApp As Outlook.Application
Set olApp = CreateObject("Outlook.Application")

' Logon. Doesn't hurt if you are already running and logged on...
Dim olNs As Outlook.NameSpace
Set olNs = olApp.GetNamespace("MAPI")
olNs.Logon

' Send a message to your new contact.
Dim olMail As Outlook.MailItem

Set olMail = olApp.CreateItem(olMailItem)
' Fill out & send message...
olMail.To = Recipient
olMail.Subject = Subject
olMail.Body = Body

olMail.Attachments.Add Attachment

olMail.Send
' Clean up...
'MsgBox "All done...", vbMsgBoxSetForeground
olNs.Logoff
Set olNs = Nothing
Set olMail = Nothing
Set olAppt = Nothing
Set olItem = Nothing
Set olApp = Nothing

End Function

Just paste this function in a module. Make sure you have a reference to ‘Microsoft Outlook 9.0 Object library’ checked in the
‘Tools/References’ menu, reachable from the module.

Test the function from the debug window by typing from instance:


?MailWithAttachment("mailbox@domainname.com"," _
   & "YourSubjectTextHere", " _
   & "YourBodyTextHere", " _
   & "c:\\MyFile.txt")

The parameters are easy:
Recipient = email address to sent your mail TO
Subject = Subject of your message
Body = Body text of your message
Attachment = filename for the attachment

Once the function is finished, you should have an email in your Outlook outbox, ready to be sent next time you check your email.

Create a linked table with VBA

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

Usually we would just need to refresh the existing linked tables, but in some cases, it is necessary to create a linked table from scratch.
This is useful when linking a text file or Excel sheet which name changes over the time.


public sub ReconnectTable(sTable, sConnect)
Dim db as Database
Dim td As TableDef

on error goto Err_Reconnect
   Set db = currentdb()

on error resume next
' Delete the table
   db.TableDefs.Delete sTable
on error goto Err_Reconnect

' Create the table def.
   Set td = db.CreateTableDef(sTable)
' Connect the table
   td.Connect = ";DATABASE=" & sConnect & ";"
' Set the source table name
   td.SourceTableName = sTable
' Add the table def to the tabledefs collection
   db.TableDefs.Append td
' refresh the link
   td.RefreshLink

db.close

exit sub

Err_Reconnect:
   msgbox "Error while reconnecting table " & sTable & ": " & error$

end sub


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