Results 1 to 3 of 3
  1. #1
    sgroth is offline Novice
    Windows XP Access 2002
    Join Date
    Jun 2011
    Posts
    2

    Update Database on Lose Focus event

    I'm building a database to provide name and phone number information to 3 telemarketing reps and give them a form to record the information they collect on the call. The trick is that once one person has started a call with a particular lead, I don't want it to be visible to the other reps -- so they don't call the same person.
    I've got the information and data entry set up on a single screen driven by a query that filters out any leads that have been called by any of the other reps (as indicated by the rep typing in his initials at the beginning of the call). However, the screen doesn't refresh the query unless you open or close the screen. To solve this I added a button that calls Me.Requery.
    The problem I still can't resolve is that when a rep starts a call, the database isn't updated with his initials until after he moves on to the next record. So if another rep pulls up that same contact it will look like it's available to call. I want the record to be invisible to other reps as soon as any rep enters his initials. I've tried to set up a lose focus event on the initials field to update the database, but I keep getting a "Too few parameters" error.



    Private Sub ISS_Initials_LostFocus()
    CurrentDb.Execute ("update [call log] set [ISS Initials] = Me.ISS_Initials.oldValue where [call log].[acct num] = me.acct_num;")
    End Sub

    Thanks to anyone who can help.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,921
    You have to save/commit the record to table before can be updated. A record is committed when form closes or move to another record or DoCmd.RunCommand acCmdSaveRecord. The inititals textbox is bound to field in table? Should not need the Execute and UPDATE sql method, use DoCmd instead.

    Syntax for the UPDATE would have to concatenate the initials and acct_num criteria:
    "UPDATE [call log] SET [ISS Initials]='" & Me.ISS_Initials.oldValue & "' WHERE [acct num]='" & Me.acct_num & "';"
    Also, the parenthesis might not be needed, maybe even a problem.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    sgroth is offline Novice
    Windows XP Access 2002
    Join Date
    Jun 2011
    Posts
    2

    Thumbs up You da man, June7!

    DoCmd.RunCommand acCmdSaveRecord worked like a charm!

    Thanks for your help!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Any change of focus on form Event?
    By trb5016 in forum Forms
    Replies: 1
    Last Post: 02-11-2011, 08:25 PM
  2. User focus control in AfterUpdate event
    By nosliwmada@gmailcom in forum Programming
    Replies: 3
    Last Post: 12-20-2010, 12:51 PM
  3. Before Update Event
    By randolphoralph in forum Programming
    Replies: 0
    Last Post: 06-15-2010, 09:26 AM
  4. Syntax For After Update Event
    By MuskokaMad in forum Forms
    Replies: 14
    Last Post: 03-12-2010, 01:48 PM
  5. Form does not update after event
    By pedro in forum Forms
    Replies: 10
    Last Post: 12-23-2009, 07:54 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums