code goes too fast

  • Thread starter Thread starter Jean-Paul
  • Start date Start date
J

Jean-Paul

Hi,
Upon clicking a pushbutton this code runs:

DoCmd.GoToRecord , , acNewRec
Me!Naam.SetFocus
Dim ontvanger As String
Dim db As Database
Dim Tb As Recordset
Dim sql As String
Set db = CurrentDb()
sql = "SELECT Setup.* FROM Setup WHERE Setup.omschrijving='Database';"
Set Tb = db.OpenRecordset(sql)
ontvanger = Tb!Detail
SubjectBox = "Aanpassen database Sales met nieuwe input van " &
Forms!hoofdmenu!Tekst24
MessageBox = ""
DoCmd.SendObject acSendReport, "Fiche", acFormatHTML, ontvanger, ,
, [SubjectBox], [MessageBox], -1


the idea is to add a record and the send a mail to somebody where all
data is centralized.

Now, when I click the "add" button the code doesn't "wait" untill all
data is entered before the mail is send.

What to do?

Thanks
 
You need to separate your code into two procedures. Run one procedure to add
the new record (DoCmd.GoToRecord step). Run the other procedure to do the
emailing action. In other words, use two buttons, not one.
 
Back
Top