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

Last reviewed: August 28, 1997
Article ID: Q141625
The information in this article applies to:
  • Microsoft Access versions 7.0, 97

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:

   ARTICLE-ID: Q148857
   TITLE     : 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.

  1. Open the sample database Northwind.mdb.

  2. 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
          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
    
    

  3. 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
    
    

  4. Open the Employees form in Design view.

  5. 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])
    

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

REFERENCES

For more information about the AutoDialer feature, search the Help Index for "AutoDialer."

For more information about the Declare statement, search the Help Index for "Declare Statement."

Keywords          : kbprg PgmApi
Version           : 7.0 97
Platform          : WINDOWS
Hardware          : x86
Issue type        : kbinfo


================================================================================


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: August 28, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.