Article ID: 837146
Article Last Modified on 5/13/2004
APPLIES TO
- Microsoft Office Access 2003
- Microsoft Access 2002 Standard Edition
- Microsoft Access 2000 Standard Edition
This article applies to a Microsoft Access database (.mdb) and to a Microsoft Access project (.adp).
Advanced: Requires expert coding, interoperability, and multiuser skills.
SYMPTOMS
When you use the AutoDialer feature in Microsoft Access, the dialing rules that are set in Access are ignored.
For example, you may set a dialing rule to dial 9 so that you can access an outside phone line for a long-distance phone call. When you use the AutoDialer feature in Access to dial the long-distance phone call, the AutoDialer feature does not prefix the long-distance phone number with 9.
WORKAROUND
To work around this problem, create a form that has the functionality that is similar to the functionality of the AutoDialer feature, and then use the form. To do this, follow these steps:
- Start Access.
- Create a new Access database.
- In the Database window, click Forms in the Objects section.
- In the right pane, double-click Create form in Design View.
Create a form. Name the form frmAutoDialXP. The frmAutoDialXP form must have a command button and a text box as follows:
Form ----------------------------------- Form Name: frmAutoDialXP Form Caption: AutoDialer XP Command Button ------------------------------------ Name: Button_OK Caption: &OK Command Button ------------------------------------ Name: Button_Cancel Caption: &Cancel Command Button ------------------------------------ Name: Button_Setup Caption: &Setup... Text Box ------------------------------------ Name: Text_PhoneNumber Text Box ------------------------------------ Name: Text_Warn
- Change the Caption property of the Text3 label to Phone number.
- On the View menu, click Code.
Replace the existing code with the following code in the Visual Basic Editor:
Option Compare Database Option Explicit 'The code for this form requires the module 'basAutoDialXP' to work. Private Sub Button_OK_Click() On Error GoTo Button_OK_Click_Err ' Variable to hold the phone number. Dim stPhoneNumber As String ' Variable to hold the return code from the API call. Dim lResult As Long ' Variables to hold error messages. Dim stNTNotSupported As String Dim stErrorDialing As String Dim stInvalidChars As String stErrorDialing = "An error occurred when dialing the phone number." 'Set the phone number to the value that is shown in the form. stPhoneNumber = Nz(Me.Text_PhoneNumber.Value) lResult = tapiRequestMakeCall(stPhoneNumber, "", "", "") If lResult <> 0 Then MsgBox stErrorDialing, vbOKOnly + vbInformation GoTo Button_OK_Click_Exit End If Button_OK_Click_Exit: 'Uncomment to automatically close frmAutoDialXP. DoCmd.Close acForm, Me.Name Exit Sub Button_OK_Click_Err: sDisplayError Err.Number, Err.Description Resume Button_OK_Click_Exit End Sub Private Sub Button_Cancel_Click() On Error Resume Next DoCmd.Close acForm, Me.Name End Sub Private Sub Button_Setup_Click() On Error GoTo Button_Setup_Click_Err Shell "control.exe modem.cpl", WindowStyle:=1 Button_Setup_Click_Exit: Exit Sub Button_Setup_Click_Err: sDisplayError Err.Number, Err.Description Resume Button_Setup_Click_Exit End Sub Private Function FValidPhoneNumber(ByRef stPhoneNumber As String) As Boolean Dim ich As Integer Dim ichLen As Integer Dim stCh As String Dim stPhoneClean As String Dim stValidChars As String Dim boolInvalidCharsFound As Boolean 'Get the length of the phone number that is based on the number of characters. ichLen = Len(stPhoneNumber) 'Initialize variables. stPhoneClean = "" boolInvalidCharsFound = True 'This routine loops through each character in the phone number and then strips non-valid characters. 'Non-valid characters are letters and characters that are not in the strValidChars variable. stValidChars = "01234567890- ,*#+()" For ich = 1 To ichLen stCh = Mid$(stPhoneNumber, ich, 1) If InStr(stValidChars, stCh) > 0 Then stPhoneClean = stPhoneClean & stCh Else boolInvalidCharsFound = False End If Next ich 'Set the phone number to the revised phone number. stPhoneNumber = stPhoneClean FValidPhoneNumber = boolInvalidCharsFound 'FValidPhoneNumber = (Len(stPhoneClean) > 0) End Function Private Sub Form_Load() 'This code makes an educated guess as to the type of phone number that is being 'passed and then tries to apply the correct canonical format. 'You must examine this code and then make any changes that you may have to. Dim strPhoneInput As String Dim strPhoneCanon As String Dim boolPhoneWarn As Boolean Dim strPhoneWarn As String Dim intPhoneInputLen As Integer 'Set initial values. strPhoneInput = Nz(Me.OpenArgs, "") boolPhoneWarn = False strPhoneWarn = "This phone number may not dial correctly. " & _ "Double check the phone number. Make sure that the phone number conforms " & _ "to the correct canonical format, and that the phone number does not contain non-valid characters." & vbCrLf & _ "Example: +1 (425) 555-0187" 'Check for non-valid characters. If Not FValidPhoneNumber(strPhoneInput) Then boolPhoneWarn = True End If intPhoneInputLen = Len(strPhoneInput) Select Case intPhoneInputLen Case 0 'No phone number is passed. strPhoneCanon = strPhoneInput boolPhoneWarn = True Case 7 'Format = '5550187' Local Call strPhoneCanon = Left(strPhoneInput, 3) & "-" & Right(strPhoneInput, 4) Case 8 'Format = '555-0187' Local Call strPhoneCanon = strPhoneInput Case 10 'Format = '7045550187' strPhoneCanon = "+1 (" & Left(strPhoneInput, 3) & ") " & Mid(strPhoneInput, 4, 3) & "-" & Right(strPhoneInput, 4) Case 12 'Format = '(704)5550187' or '704 555-0187' or '704-555-0187' If InStr(1, strPhoneInput, "(") > 0 Then strPhoneCanon = "+1 " & Left(strPhoneInput, 5) & " " & Mid(strPhoneInput, 6, 3) & "-" & Right(strPhoneInput, 4) ElseIf Mid(strPhoneInput, 4, 1) = Chr(32) Then strPhoneCanon = "+1 (" & Left(strPhoneInput, 3) & ")" & " " & Mid(strPhoneInput, 5) Else strPhoneCanon = "+1 (" & Left(strPhoneInput, 3) & ") " & Mid(strPhoneInput, 5) End If Case 13 'Format = '(704)555-0187' strPhoneCanon = "+1 " & Left(strPhoneInput, 5) & " " & Right(strPhoneInput, 8) Case 14 'Format = '(704) 555-0187' strPhoneCanon = "+1 " & strPhoneInput Case 17 'Format = '+1 (704) 555-0187' strPhoneCanon = strPhoneInput Case Else strPhoneCanon = strPhoneInput boolPhoneWarn = True End Select If boolPhoneWarn = True Then Me.Text_Warn.Value = strPhoneWarn End If Me.Text_PhoneNumber.Value = strPhoneCanon Form_Load_Exit: Exit Sub Form_Load_Err: sDisplayError Err.Number, Err.Description Resume Form_Load_Exit End Sub
- On the File menu, click Close and Return to Microsoft Office Access.
- In the Database window, click Save on the File menu.
- In the Save As dialog box, type frmAutoDialXP in the Form Name box, and then click OK.
- On the File menu, click Close.
- In the Database window, click Modules in the Objects section.
- Click New.
Replace the existing code with the following code in the Visual Basic Editor:
Option Compare Database Option Explicit 'This module is required for the revised AutoDial form (frmAutoDialXP) 'that replaces the one that is included with Access. 'This AutoDial feature is compatible with Microsoft Windows 2000 dialing rules and with Windows XP dialing rules. 'API Function Declaration. Declare Function tapiRequestMakeCall Lib "tapi32" _ (ByVal lpszDestAddress As String, _ ByVal lpszAppName As String, _ ByVal lpszCalledParty As String, _ ByVal lpszComment As String) As Long 'Function to open frmAutoDialXP. Function sOpenDialer(strPhoneNumber As String) DoCmd.OpenForm "frmAutoDialXP", acNormal, , , , acDialog, strPhoneNumber End Function 'Function to display error messages. Function sDisplayError(strErrNumber As String, strErrDescription As String) MsgBox "An error has occurred." & vbCrLf & vbCrLf & _ "Error Number: " & strErrNumber & vbCrLf & vbCrLf & _ "Error Description: " & strErrDescription, vbOKOnly + vbExclamation End Function
- On the File menu, click Save
<database name>
. - In the Save As dialog box, type basAutoDialXP in the Module Name box, and then click OK.
- On the File menu, click Close and Return to Microsoft Office Access.
- Add an AutoDial button to the frmAutoDialXP form. To do this, follow these steps:
- In the Database window, click Forms under Objects.
- In the right pane, locate the frmAutoDialXP form. Right-click the frmAutoDialXP form, and then click Design View.
- Add a command button to the frmAutoDialXP form.
- In the Command Button Wizard, click Miscellaneous under Categories.
- Under Actions, click AutoDial, and then click Finish.
- On the View menu, click Code.
Locate the following code:
Application.Run "utility.wlib_AutoDial", stDialStr
Replace the previous code with the following code:
sOpenDialer (stDialStr)
- On the File menu, click Save
<database name>
. - On the File menu, click Close and Return to Microsoft Office Access.
- Open the frmAutoDialXP form.
- In the Phone number box, type +1 (09) 425-5550187, and then click OK.
MORE INFORMATION
Steps to reproduce the problem
- To create a dialing rule, follow these steps:
- If you are using Windows 2000 or the Classic Start menu in Windows XP or in Windows Server 2003, click Start, point to Settings, and then click Control Panel.
If you are using Windows XP or Windows Server 2003 and the menu is not the Classic Start menu, click Start, and then click Control Panel. - In Control Panel, click Phone and Modem Options.
- On the Dialing Rules tab, click New to create a Location profile for the first time.
- In the Location box, type testLocation.
- In the Area code box, type 425.
- In the To access an outside line for long distance calls, dial box, type 9.
- Click OK.
- On the Phone and Modem Options, click OK.
- If you are using Windows 2000 or the Classic Start menu in Windows XP or in Windows Server 2003, click Start, point to Settings, and then click Control Panel.
- Start Access.
- Create a new database.
Create a new table. Name the table testTable.
The columns details for the table follow:
Field name phoneNumber Data type text
- Open the testTable table in Datasheet view.
- In the phoneNumber column, type +1 (09) 425-5550187.
- On the View menu, point to Toolbars, and then click Customize.
- On the Commands tab, click Records in the Categories list.
- In the Commands list, click AutoDialer, and then add AutoDialer to the Datasheet view toolbar.
- Click Close.
- In Datasheet view, click the phone number that you want to dial.
- On the toolbar, click AutoDialer.
- In the AutoDialer dialog box, click OK.
Notice that the AutoDialer feature does not prefix the phone number with 9.
REFERENCES
For additional information, click the following article number to view the article in the Microsoft Knowledge Base:
247192 You must enter telephone numbers in canonical form in order to use dialing rules
Additional query words: Acc2000 Acc2002 Acc2003 Autodial
Keywords: kbprb KB837146