Results 1 to 4 of 4
  1. #1
    comicwizard is offline Novice
    Windows 2K Access 2003
    Join Date
    Apr 2011
    Posts
    2

    Form using VBA to update field on table

    Hello, I have a simple form which has two things. One a cbo box which contains names. The other is a button. This button does two things. It checks the choosen name from the cbo box then using that name filters a report and opens that report and attaches that report to an email.



    I need to do one more thing. I have a table where these names are pulled from. There is a yes/no field labeled email. I need to be able to check that field when I send out the report to that particular person. I have included my code. The codes does everything but update the email yes/no field. Please help. Btw I have a deadline for this.

    Private Sub Open_Feedback_Click()
    On Error GoTo Err_Open_Feedback_Click

    Dim stDocName As String
    stDocName = "Daily_Feedback"

    DoCmd.OpenReport "Daily_Feedback", acPreview, , "[Sup_Email]='" & Me.cbosupervisor_name & "'"

    DoCmd.SendObject acReport, "Daily_Feedback", "SnapshotFormat(*.snp)", "", "", "", "Daily Feedback Report", "Included is the daily Feedback Report", True, ""

    Exit_Open_Feedback_Click:
    Exit Sub

    Err_Open_Feedback_Click:
    MsgBox Err.Description
    Resume Exit_Open_Feedback_Click

    End Sub

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    How many times do you send an email to a specific person? You do not indicate WHEN this email was sent. Seems it would be important.

  3. #3
    comicwizard is offline Novice
    Windows 2K Access 2003
    Join Date
    Apr 2011
    Posts
    2
    ah let me provide more information. The cbo box has a filter for the email yes/no field. So once a name is choosen, the report sent and the email yes/no field updated it shouldn't show up there again. This way as the report go out to different people, they won't be send the report again.

    Is there anything else I may provide? I can show screen shots, and other things if that would help.

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    So you only send one email to people in your table. OK
    So you will need code like this
    Code:
    Dim mySQL as string
    
    mySQL = "Update YourTable " _
    & "Set EmailY_N = True " _
    & "Where Person = '" & ThePersonYouSentEmailTo & ''"
    
    db.Execute mySQL, dbfailonerror
    Put the Dim under your existing Dim

    Put the rest after the Docmd.SendObject line

    I'm not sure how you are getting the name of the person so some adjustment to the sql my be required.

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

Similar Threads

  1. Replies: 3
    Last Post: 10-30-2013, 11:42 AM
  2. Replies: 3
    Last Post: 01-17-2011, 01:48 AM
  3. Update field in table after update on a subform
    By jpkeller55 in forum Queries
    Replies: 3
    Last Post: 09-30-2010, 08:02 PM
  4. Replies: 4
    Last Post: 09-03-2009, 02:01 PM
  5. Update table from calculated field in a form
    By BernardKane in forum Forms
    Replies: 3
    Last Post: 11-28-2006, 09:48 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