Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending Email from Continuous Form 1

Status
Not open for further replies.

NoelMG

Programmer
Dec 5, 2003
23
0
0
GB
I have a continuous form (it's an Action List) in an Access database. Basically, I want the user to click the Submit button and it to run some code to modify some data, append to another database and send me an email.

The "Submit" button is against each record.

The code is all working correctly, however, when I click it it generates the email etc for the first record in the form each time, even if I click the button against say the last record.

Is there a way of making this command button work just for the record it's on?

Cheers,
Noel.
 
Sorry I guess the code I'm using behind the button would help!

Code:
Private Sub Command25_Click()

'Dim stDocName As String
Dim outApp As Outlook.Application, outMsg As MailItem
Set outApp = CreateObject("Outlook.Application")
Set outMsg = outApp.CreateItem(olMailItem)


        'Set status as Not Started
    Me.Status = "Not Started"
        'Copy the Application Title and path into the Action Table
    Me.AppTitle = Application.CurrentDb.Properties("AppTitle")
    Me.AppPath = Application.CurrentDb.Name
        'Export the new action item to the Admin database by running an append query
    DoCmd.SetWarnings False

    DoCmd.OpenQuery "qryActionListExport"
        'Mark the item as submitted
    Me.Submitted = -1
    Me.Requery
        
        'Send an Email to Noel advising of the new task


    With outMsg
        .To = "Noel Marsh-Giddings"
        .CC = [Forms]![frmActionList]![ActionReqBy]
        .Subject = "New Action Item in " & Application.CurrentDb.Properties("AppTitle")
        .Body = "There is a new Action Item in the " & Application.CurrentDb.Properties("AppTitle") & " database from " & [Forms]![frmActionList]![ActionReqBy] & ".  " & vbCr & vbCr & "Action Item Title: " & [Forms]![frmActionList]![ActionTitle] & vbCr & "Due Date: " & [Forms]![frmActionList]![DueDate] & vbCr & "Path: " & Application.CurrentDb.Name
            
        
Fini:
        
        .Send
        End With
        
        
        
        
        
        End Sub
 
If you need to save the current record, use me.refresh or docmd.runcommand accmdsaverecord in stead of me.requery (which is the command making the first record selected).

Roy-Vidar
 
Thanks so much for that Roy - I used Me.refresh and it worked fine!

Had no idea it was something so simple!

Cheers,
Noel.
 
Is the query appending the correct record? If so, assign the values to variables and pass the variables to the email portion of the code.

Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top