Button Code will only run once??

Steven Pyrah

New member
Local time
Today, 10:02
Joined
Jan 11, 2003
Messages
7
I have a button on my form that e-mails fields from that form. The code works fine, it picks up everything I need and mails it to everyone it should.

Problem is this, once the database has sent 1 record (1 e-mail) it will not run again when I create a new record. I have to close and repair the database before it will run again.

Can anyone see any holes in the code I have found and modified from this forum.


Private Sub Command51_Click()

Dim stMsg As String
Dim stBCC As String
Dim stTO As String

stTO = Me.[Mail1] & "; " & Me.[Mail2]
stCC = Me.[TL1] & "; " & Me.[TL2]
stMsg = "(" & Me.[First Applicant] & ")" & " has swapped this shift (" & Me.[First Applicants Shift] & ") and this lunch (" & Me.[1st App Lunch] & ") on this date (" & [Date Wanting To Swap] & ") with (" & Me.[Second Applicant] & ") and their shift of (" & Me.[Second Applicants Shift] & ") and lunch at (" & Me.[2nd App Lunch] & ") on this date (" & Me.[Date Wanting To Swap (Second)] & ")" & vbCrLf & vbCrLf & "NOTES" & vbCrLf & vbCrLf & Me.[Notes] & vbCrLf & vbCrLf & vbCrLf & vbCrLf & vbCrLf & vbCrLf & "Please keep this e-mail safe as it is your proof that the shift swap has been authorised by (" & Me.[Authorised_By] & ")" & vbCrLf & "Thank You"
DoCmd.SendObject , , , stTO, stCC, stBCC, "Shift Swap Notification Produced By CCD", stMsg, False

End Sub

Any help would be great

Thanks
 
On the off chance...
it will not run again when I create a new record.
Would you save the record first to include it in the recordset?
just a thought
Dave
 
Thanks for the reply

No it does not have to be saved first to the record set before the e-mail fires.

Is there some sort of reset code I can use after my code. I know that it will work if I close the database and then reopen it so it must be something to do with the code only running the once and then not being able to run a second or third time.

Thanks again
 
I have been advised that this is an Access 2000 fault that has since been sorted by Access 2002.

The fix is to put the code in to a macro or buy Access 2002!!

Question 2......

How do I put my above code in to a macro that will collect all the data from the form??:confused:
 

Users who are viewing this thread

Back
Top Bottom