Microsoft Access Tips

A few of the functions we've used in DataHouse and Pipeline. Please feel free to use all and any tips, code etc in your own applications. All tips, code etc is provided without any warranty implied, use at your own risk.



Skype and MS Access - Making a call using Skype
  1. Double clicking the text box containing the phone number runs the function CallToNumber and passes it the number in the text box.
  2. CallToNumber
    • Takes the number passed from the double click event.
    • Strips away the following characters from the number: " ", "-", "(" and ")"
    • Checks the first character,
      • if this is a "+", the function assumes the number is formatted as an international number such as "+61245674567".
      • If this is a "0", then this zero is replaced with "+" and the country code specified on another form
    • Initiates the call. If Skype is properly installed it will start dialling now.
  3. Should work with other VOIP software too, nothing in the code is Skype specific

	===

        Private Sub txtContactMobile_DblClick(Cancel As Integer) 
        On Error GoTo HandleErr

	     CallToNumber ([txtContactMobile])
    
	ExitHere:
	  Exit Sub

	HandleErr:
	  MsgBox "Error"

	End Sub
	===

	Public Function CallToNumber(strNumber As String) 
        On Error GoTo HandleErr

	    Dim strPhoneNumberCleaned, strFirstDigit, strCall, strCountryCode, stLink As String

	    strCountryCode = [Forms]![frmCurrentUserDetails]![txtCountryCode]
	    strPhoneNumberCleaned = Replace((Replace((Replace((Replace(strNumber, " ", "")), "-", "")), "(", "")), ")", "")
	    strFirstDigit = Left(strPhoneNumberCleaned, 1)
    
	    strCall = strCountryCode & strPhoneNumberCleaned
    
	    If strFirstDigit = "+" Then
	        strCall = strPhoneNumberCleaned
	    End If
        
	    If strFirstDigit = "0" Then
	        strCall = strCountryCode & Right(strPhoneNumberCleaned, (Len(strPhoneNumberCleaned) - 1))
	    End If
    
            
	    stLink = "callto://" & strCall
	    Application.FollowHyperlink stLink
    

	ExitHere:
 	  Exit Function

	HandleErr:
	  MsgBox "Error"

	End Function

These Access tips are brought to you by DataHouseSoftware creators of Pipeline and DataHouse