Results 1 to 13 of 13
  1. #1
    Lounger
    Join Date
    Sep 2001
    Posts
    41
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Check form for responses and send report (Access/2002)

    I have a database I am working on which has a form that collects answers to about 40 questions (each with a value of 1, 2, 3 if clicked) by way of a radial selection. The user will supply information and then select the responses if any that should be checked/toggled. At the end of this form I want to put in a check box that would, if selected, check the 40 questions for answers. I have a query and report for this but I am not sure how to write the code to check the form for the current entry that is being used.

    Ultimately what I would like to do is check the form for values and if there are values in certain questions e-mail a report for quicker response to problems.

    I would assume that this would be an if then statement or if elseif statement but I am just not sure how to write it aside from the basic statement itself.

    Private Sub Check1502_Click()

    If Me.SReSp > 0 Then (I am just not sure what should follow)

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Check form for responses and send report (Access/2002)

    You can use an instruction such as

    DoCmd.SendObject acSendReport, "rptSomething", acFormatRTF, "me@somewhere.com", , , "Problem Report", "See attachment"

    to send a report by e-mail. But if you want specific help, you'll have to provide much more information.

    BTW, I'd use a command button instead of a check box.

  3. #3
    Star Lounger
    Join Date
    Jul 2007
    Location
    North Carolina, USA
    Posts
    71
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Re: Check form for responses and send report (Access/2002)

    Using the report method, am I able to put the information in the body vise an attachment?
    Is there a way to send fields from a subform and mainform, while keeping it on the current record? (Everytime I try to use data from a subform within a report it gives me an error)

    As for the IF Statement portion:

    I am creating Requests, and the Requests that are TYPE = A, have the information from the Main Form and Sub Form sent to the email group TeamA@request.com where as the Requests that are TYPE=B, have the information from the Main Form and the Sub Form sent to the email group TeamB@request.com. (This of course is based on the entry made in the Type field.)

    The Main Form contains the Request Information and the Sub Form contains the Employee information.
    Within the Request Table there are two feilds that pull from the Employee Table, sometimes it is the same Employee for both and other times it is two different employees.

    I was able to use what you sent me earlier to have it put the correct fields in the body of the text and have it sent to one email but not based on the entry made in the Type field.

    Also, I am having an issue with the Subform data. On my Form in Form View, the information is displayed properly, but when I send it to the email, it puts the Control Source for the field rather than the information that I see on the form. I am not sure what information you would need to be able to assist, but I would be glad to provide more details if your willing to help resolve this issue.

    Thanks again for your help, it is great to have someone to bounce the confusing ones off of. I really appreciate it.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Check form for responses and send report (Access/2002)

    Did you really mean to post your reply in this thread? Or is it a glitch of the Lounge software?

  5. #5
    Lounger
    Join Date
    Sep 2001
    Posts
    41
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Check form for responses and send report (Access/2002)

    I am trying to pull together the information from the current record into a report and then send it. Using the information you provided along with the below code I thought this would work but I get a "type mismatch." Can you provide any help on how I can pull together the current information in the form into a report and then send that same report to an email recipient?

    Private Sub emailapp_Click()
    On Error GoTo Err_emailapp_Click


    If Me.SRSp > 0 Then
    DoCmd.OpenReport "Rptappwpblmsemail", acFormatRTF, , "[AppID] = " & Me.[AppID]

    DoCmd.SendObject acSendReport, "Rptappwpblmsemail", acFormatRTF, "someone@somewhere.com", , , "Problem Report 1 ", "Please See attachment "

    Else: MsgBox "Thank you for submitting ", vbInformation


    Exit_emailapp_Click:
    Exit Sub

    Err_emailapp_Click:
    MsgBox Err.Description
    Resume Exit_emailapp_Click

    End If
    End Sub

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Check form for responses and send report (Access/2002)

    Please comment out the line

    On Error GoTo Err_emailapp_Click

    temporarily (by inserting an apostrophe ' in front of it). Then try again. When the error message is displayed, click the Debug button. Which line is highlighted?

  7. #7
    Lounger
    Join Date
    Sep 2001
    Posts
    41
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Check form for responses and send report (Access/2002)

    DoCmd.OpenReport "Rptappwpblmsemail", acFormatRTF, , "[ApplicationID] = " & Me.[ApplicationID]

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Check form for responses and send report (Access/2002)

    Sorry, should have seen that. acFormatRTF is not valid while opening a report, only when exporting or sending. You should use acViewPreview instead.

    And since you want to send the currently open object, change the SendObject line to

    DoCmd.SendObject acSendReport, , acFormatRTF, "someone@somewhere.com", , , "Problem Report 1 ", "Please See attachment "

  9. #9
    Lounger
    Join Date
    Sep 2001
    Posts
    41
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Check form for responses and send report (Access/2002)

    Thanks that works and generates the report for the e-mail but bring up one other issue. The same line:

    DoCmd.OpenReport "Rptappwpblmsemail", acPreview, , "[Applicationid] = " & Me.[ApplicationID]

    I thought the filter would work for the Applicationid however it brings up an Enter Parameter Value box with the value of ApplicationID. I thought I was filtering for this number? Can I eliminate this box or make it fillin the parameter value by changing the above code?

  10. #10
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Check form for responses and send report (Access/2002)

    "[Applicationid] = " & Me.[ApplicationID] will only work if your form (referred to as "Me") contains a control or field named ApplicationID, and if the record source of the report also contains a field named ApplicationID. Check carefully.

  11. #11
    Lounger
    Join Date
    Sep 2001
    Posts
    41
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Check form for responses and send report (Access/2002)

    The control source in the form is ApplicationID and the record source of the report contains a field named ApplicationID. There is a textbox name but the record source is ApplicationID. The question that comes up for the Parameter Value ask for the correct value. For instance if the value is 123 it looks like this:

    |Enter Parameter Value|
    | 123 |
    | _____________ |
    | ok cancel |
    | _________________|



    Do I need to change the field for TEXT to chr (25) I tried this and get an error as well.

    DoCmd.OpenReport "Rptappwpblmsemail", acPreview, , "[Applicationid] = " & Chr (10) & Me.[ApplicationID] Chr (10)

  12. #12
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Check form for responses and send report (Access/2002)

    Try this:

    DoCmd.OpenReport "Rptappwpblmsemail", acPreview, , "[Applicationid] = " & Chr(34) & Me.[ApplicationID] & Chr(34)

    Chr(34) is the double quote character ", it is needed to surround text values.

  13. #13
    Lounger
    Join Date
    Sep 2001
    Posts
    41
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Check form for responses and send report (Access/2002)

    That worked great I tried that before but I was getting errors I think I left out an &

    Thank you for all of your help and explainations.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •