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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form completed (record added) = email notification

Status
Not open for further replies.

mattpearcey

Technical User
Mar 7, 2001
302
GB
I have just introduced two new forms to my database, to incorporate an area to enter new information. Certain people, ie. managers, need to view this new information as soon as this is entered. Is there a way that i can make a button a required field? For example, like when you make up a new table, you can make a field required. Then this button, because it is required, must be pressed upon filling in a new record - it will then email a userlist to notify them that a new record has been added, and which record it is.

Is this possible? Thank you for your help already.

Matt Pearcey
 
I'm not sure you can make a field "required" (only cause I've never tried it) However, what I've done in the passed, is have a field in the talbe called "CompleteFlag" or something like that.

Then on my form, I have an invisible check box, bound to this field. Now, I then apply a little back end code to maybe the last field in the form that says:

Code:
Sub MyField_AfterUpdate
 If Not IsNull(MyFiild) Then
   MyChkBox = True
 End If
End Sub

This code makes the check box true (and also inserts the value in the table

Next you just have some code behind the close button (or Form_Close event) that checks the chkbox field...like this

Code:
Sub Form_Close()
   If Me!MyChkBox <> True Then
      Beep
      MsgBox &quot;Oy! Don't forget to fill in all the fields!&quot;
      MyField.Setfocus
   End If
End Sub


Of course you could always go down the route of an Input Mask for the field, but that only checks against the value being entered! If it's blank, chances are it will be overlooked anyway

Hope this helps!

birklea birklea ~©¿©~ <><
I know what I know...don't presume that I know what I don't! Smithism!!!
 
Hi Matt. I have a work order system where the user completes a form to submit a work order/project to the MIS department. When they finish filling out the form they click on the Submit button. The onclick event behind the Submit button saves the new record, opens up a report advising the user that their work order has been received by MIS, and sends email to me telling me a new work order has been added to the database. (Of course, I have my email set to automically notify me when I receive new email.) Maybe you can adapt this code (particulary the DoCmd.SendObject line) to your purposes. Good luck.

Ann

Private Sub Command63_Click()
Dim stDocName As String


If Me.[Frame30] = -1 And (IsNull(Me.[NLTDate]) Or IsNull(Me.[Impact])) Then
DoCmd.OpenForm &quot;frmMsgBox--NoImpactStmt&quot;
Else
DoCmd.RunCommand acCmdSaveRecord
DoCmd.Requery &quot;ProjectNumber&quot;
DoCmd.SendObject , , acFormatRTF, &quot;ann@bionetics.com&quot;, , , _
&quot;A new WO has been added&quot;, , 0

stDocName = &quot;rptProjectStatusFromConfirmation&quot;
DoCmd.OpenReport stDocName, acPreview, , &quot;ProjectNumber =&quot; & ProjectNumber
DoCmd.Close acForm, &quot;frmProjects--DE&quot;
End If

End Sub
 
No, there is noway to make a button required--the button is a partt of the form, not the record in the table.

In a bound form, I would say tha the best solution here is to put code in the AfterInsert event of the form. That gets fired every time a new record is added.

To use this system, though, you will most likely want to have code in the beforeInsert event that validates all of the data--making sure you have legit data in all of the fields where it's needed. Do this is in the BeforeInsert because you can cancel this event. Do the other stuff in the AfterInsert because then you'll have everything in the table, and you'll be able to rely on whatever query or sql you use to get the values into the e-mail.

Jeremy =============
Jeremy Wallace
Designing, Developing, and Deploying Access Databases Since 1995

Take a look at the Developer's section of the site for some helpful fundamentals.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top