Solved

Microsoft Access - Update Company Records based on Phone Numbers

Posted on 2016-08-20
5
54 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:OAC Technology
  • 2
  • 2
5 Comments
 
LVL 2

Accepted Solution

by:
Antonio Salva Ripoll earned 450 total points
ID: 41763889
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:OAC Technology
ID: 41764512
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
ID: 41764815
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:OAC Technology
ID: 41769355
You guys did it! Thank you!
0
 
LVL 49

Expert Comment

by:Gustav Brock
ID: 41769794
You are welcome!

/gustav
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
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…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…

820 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