Solved

Microsoft Access - Update Company Records based on Phone Numbers

Posted on 2016-08-20
5
42 Views
Last Modified: 2016-08-24
Greetings!

We have a Microsoft Access Database with an SQL backed that we use in house for managing our ticketing system. A former employee put it together, we love it, it has worked great for years.

I'd like to preface this with the fact that I myself don't know much about programming or Access, but just enough to figure things out as we'd like to add to or modify the program. Oddly, it has become fun and educational to figure it out on my own.

I am a little stuck on one item that we'd like to implement.

We have a form called "Phone Calls" which pulls records from a table called "CDR". Within this database, there is a field called "SRC" that contains the Caller ID number of a client who called.

I would like to be able to click on the "SRC" field within this form, and have a macro/vb script/something allow me to take the phone number that is in the "SRC" field, and copy it to the "Phone Numbers" field in another table called "Client Contacts", and allow me to associate the "SRC" phone number with an existing "Company" in the "Client Contacts" table.

Basically, what I'm looking to do is take the caller ID info of previous calls, and have an easy way of copying the phone numbers out of that table, and associating them with an existing company and phone number in our "Client Contacts" table. We have to be able to track phone calls for billing purposes, and it is extremely handy to be able to click on a client of ours in Access, and see all the related phone calls associated with that client. It would be easy to enter in if the client only called from one number, but that usually isn't the case.
Phone-Calls-Experts-Exchange-Questio.png
0
Comment
Question by:DataDudes
  • 2
  • 2
5 Comments
 
LVL 2

Accepted Solution

by:
Antonio Salva Ripoll earned 450 total points
Comment Utility
Hi @DataDudes.

Basically, what you want to do, it is not difficult. The only problem I see is to use the click event in the field, it is better to use double click.

If the control name is "txtSRC" the code you need is:

Private Sub txtSRC_DblClick(Cancel As Integer)
    
    Dim strClientName As String
    Dim rs As Recordset
    
    strClientName = InputBox("Please, enter the client name", "Add client")
    
    If strClientName = "" Then
        MsgBox "You cancelled the input of the client", vbInformation, "Add client"
        Exit Sub
    End If
    
    Set rs = CurrentDb.OpenRecordset("SELECT * FROM [Client Contacts] WHERE Company LIKE '" & strClientName & "'")
    
    If rs.EOF Then
        rs.AddNew
        rs.Fields("Company") = strClientName
    Else
        rs.Edit
    End If
    
    rs.Fields("Phone Numbers") = Me.txtSRC
    
    rs.Update
    
    rs.Close
    
    Set rs = Nothing
    
End Sub

Open in new window


This is a simple way to resolve the question.
Also, you can use an intermediary form to show all companies and select one or add the new one, but this is a little more complex and I need to know the fullnames of the tables, fields, forms and controls to give you a complete solution.

Best regards.

Antonio (Barcelona, Spain)
0
 
LVL 2

Author Comment

by:DataDudes
Comment Utility
This is helpful, thank you!

When I enter this code in and try it, I get a message that says:

Run-time error '3622'

You must use the dbSeeChanges option with OpenRecordset when accessing a SQL Server table that has an IDENTITY column.


I'm assuming there is a detail or two more you may need from me regarding my setup? : )
0
 
LVL 49

Assisted Solution

by:Gustav Brock
Gustav Brock earned 50 total points
Comment Utility
It's this line:
Set rs = CurrentDb.OpenRecordset("SELECT * FROM [Client Contacts] WHERE Company LIKE '" & strClientName & "'", dbOpenDynaset, dbSeeChanges)

Open in new window

/gustav
0
 
LVL 2

Author Comment

by:DataDudes
Comment Utility
You guys did it! Thank you!
0
 
LVL 49

Expert Comment

by:Gustav Brock
Comment Utility
You are welcome!

/gustav
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Join & Write a Comment

In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now