• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 69
  • Last Modified:

Microsoft Access - Update Company Records based on Phone Numbers

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
OAC Technology
Asked:
OAC Technology
  • 2
  • 2
2 Solutions
 
Antonio Salva RipollCommented:
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
 
OAC TechnologyProfessional NerdsAuthor Commented:
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
 
Gustav BrockCIOCommented:
It's this line:
Set rs = CurrentDb.OpenRecordset("SELECT * FROM [Client Contacts] WHERE Company LIKE '" & strClientName & "'", dbOpenDynaset, dbSeeChanges)

Open in new window

/gustav
0
 
OAC TechnologyProfessional NerdsAuthor Commented:
You guys did it! Thank you!
0
 
Gustav BrockCIOCommented:
You are welcome!

/gustav
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now