Microsoft KB Archive/141625

= ACC: Using TAPI to Dial a Phone Under Win95/NT 4.0 (95/97) =

Article ID: 141625

Article Last Modified on 1/19/2007

-

APPLIES TO


 * Microsoft Access 95 Standard Edition
 * Microsoft Access 97 Standard Edition

-



This article was previously published under Q141625



SUMMARY
Advanced: Requires expert coding, interoperability, and multiuser skills.

This article describes a sample Visual Basic function, DialNumber, that you can use to dial a telephone number from Microsoft Access 7.0 and 97 using your computer's modem. This method uses Telephony Application Programming Interface (TAPI) function calls to dial the number.

This technique provides the same behavior as the built-in AutoDialer feature in Microsoft Access 7.0 and 97.

NOTE: Although this technique works in Windows 95 and Windows NT 4.0, it may not work in Windows NT 3.51 because Windows NT 3.51 does not have built-in TAPI support. For more information about dialing a phone number in Microsoft Access without using TAPI, please see the following article here in the Microsoft Knowledge Base:

148857 ACC: How to Dial a Phone Number Using MS Access 95/97

This article assumes that you are familiar with Visual Basic for Applications and with creating Microsoft Access applications using the programming tools provided with Microsoft Access. For more information about Visual Basic for Applications, please refer to your version of the "Building Applications with Microsoft Access" manual.



MORE INFORMATION
Although the TAPI software development kit (SDK) contains a complete set of telephony functions, you need only one function, tapiRequestMakeCall, to dial a phone number.

The following steps demonstrate how to create and use the DialNumber function in Microsoft Access 7.0 and 97.

 Open the sample database Northwind.mdb.  Create a module and type the following lines in the Declarations section:

NOTE: You may have some Microsoft Windows API functions defined in an existing Microsoft Access library; therefore, your declarations may be duplicates. If you receive a duplicate procedure name error message, remove or comment out the declarations statement in your code.

NOTE: Type the Declare statement exactly as shown, including capitalization, because Win32 names are case-sensitive. Option Explicit Option Explicit Declare Function tapiRequestMakeCall Lib "tapi32.dll" _ (ByVal stNumber As String, ByVal stDummy1 As String, _        ByVal stDummy2 As String, ByVal stDummy3 As String) As Long Public Const ID_CANCEL = 2 Public Const MB_OKCANCEL = 1 Public Const MB_ICONSTOP = 16, MB_ICONINFORMATION = 64

  Type the following procedure: ' ***********************************************************     ' FUNCTION: DialNumber '     ' PURPOSE: To dial a telephone number using the computer's modem '     ' ARGUMENTS: '   PhoneNumber: The telephone number to dial '     ' EXAMPLE: '   Type the following in the Debug window to dial a phone number: '     '       ? DialNumber("555-1212") ' ***********************************************************     Function DialNumber (PhoneNumber) Dim Msg As String, MsgBoxType As Integer, MsgBoxTitle As String Dim RetVal As Long

' Ask the user to pick up the phone. Msg = "Please pickup the phone and click OK to dial " _ & PhoneNumber MsgBoxType = MB_ICONINFORMATION + MB_OKCANCEL MsgBoxTitle = "Dial Number"

If MsgBox(Msg, MsgBoxType, MsgBoxTitle) = ID_CANCEL Then Exit Function End If

' Send the telephone number to the modem. RetVal = tapiRequestMakeCall(PhoneNumber, "", "", "")

If RetVal < 0 Then Msg = "Unable to dial number " & PhoneNumber GoTo Err_DialNumber End If

Exit Function

Err_DialNumber:     'This is not an On Error routine. Msg = Msg & vbCr & vbCr & _ "Make sure no other devices are using the Com port" MsgBoxType = MB_ICONSTOP MsgBoxTitle = "Dial Number Error" MsgBox Msg, MsgBoxType, MsgBoxTitle

End Function  Open the Employees form in Design view. Add a command button to the form next to the HomePhone field and set the command button's properties as follows:

Name: btnDialPhone

Caption: Dial

OnClick: =DialNumber([HomePhone])

 View the form in Form view. To dial an employee's home phone number, click the Dial button.</ol>

<div class="references_section">