Updateing a table after comand button is pushed

mhubbard

Registered User.
Local time
Today, 14:47
Joined
Jul 31, 2002
Messages
25
I have a main form. On the main form I have a command button that luanches the auto dialer.
What I am trying to do is when that button is pressed. Update a Activities table with USERID, date, and Personid.
Not sure how to do this. It is a way for me to tell who has made calls and when.
Thanks for your help!
 
The way to do this is to update a recordset that holds that information "behind the scenes" of the button_Click event. This requires VBA code and a log table.

Suppose the log table is called LOGTABLE and has fields PERSID, USERID, and DIALTIME

Assuming you have the information available and a table exists to hold this info, your solution might be so simple as, in the button_Click's event routine, before it launches the autodialer...

Add this line at the top of the _Click routine

Dim rsLog as Recordset

Now before (or after) you launch the autodialer, add

Set rsLog = CurrentDB.OpenRecordset( "LOGTABLE" )
With rsLOG
.AddNew
![PERSID] = PersonID
![USERID] = UserID
![DIALTIME] = Now
.Update
.Close
End With

If you aren't sure about where this goes, get into design mode on the form. Click the code symbol to open the Class Module's code window. Find the event code by looking for the button's name in the drop-down on the left side just above the code window. If you don't find code that starts with

Private Sub {button-name}_Click()

then use the right side of that same location to drop down to the click event. But if your button was created by a Wizard, there should be a click event such as I described. Substitute the correct control name for {button-name}.
 
Thanks Doc Man I seem to bet getting an error of 'Type Mismatch' and I cannot figure it out. Below is the code.
Thank you!

Private Sub Command65_Click()
Dim rsLog As Recordset
On Error GoTo Err_Command65_Click
Dim intstart As Integer
Dim stDialStr As String
Dim PrevCtl As Control

Const ERR_OBJNOTEXIST = 2467
Const ERR_OBJNOTSET = 91

PhoneWork.SetFocus
Set PrevCtl = PhoneWork


If TypeOf PrevCtl Is TextBox Then
stDialStr = IIf(VarType(PrevCtl) > V_NULL, PrevCtl, "")
ElseIf TypeOf PrevCtl Is ListBox Then
stDialStr = IIf(VarType(PrevCtl) > V_NULL, PrevCtl, "")
ElseIf TypeOf PrevCtl Is ComboBox Then
stDialStr = IIf(VarType(PrevCtl) > V_NULL, PrevCtl, "")
Else
stDialStr = ""
End If


Set rsLog = CurrentDb.OpenRecordset("LOG TABLE")
With rsLog
.AddNew
![PERSID] = Personid
.Update
.Close
End With

Application.Run "utility.wlib_AutoDial", stDialStr

Exit_Command65_Click:
Exit Sub

Err_Command65_Click:
If (Err = ERR_OBJNOTEXIST) Or (Err = ERR_OBJNOTSET) Then
Resume Next
End If
MsgBox Err.Description
Resume Exit_Command65_Click

End Sub
 

Users who are viewing this thread

Back
Top Bottom