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

Problem with Command Button - Very Frustrating!

Status
Not open for further replies.

BLBurden

Technical User
Jan 25, 2003
236
0
0
US
Hello again all, I created a command button called Email. The button works fine accept for the fact that if I want to click it on the next record that I am e-mailing, it just doesn't work. I have exhusted all my means of making this work.

The only way I can make it work again is that I have to close out the DB altogher and then come back to the record and then hit the button - again and it works fine again.

I am very frustrated[cry] and can not figure out whats wrong. Her is an example of my code. Is there anywhere I can put a number and tell it to work each time I click it?

Private Sub Command222_Click()
'Prevent error screen if user cancels without sending mail.
On Error Resume Next

Dim strToWhom As String
Dim strMsgBody As String
Dim strManagers As String

strToWhom = Me!Managers

strMsgBody = strMsgBody & "SIPP# " & Me.ID & " for " & Me.Company & ", will start on " & Me.Start_Date & ". Please see attachment."

DoCmd.SendObject , , , strToWhom, Me.Project_Owner, , "SIPP's ", _
strMsgBody, True
End Sub BLB
Always Grateful
 
You have prevented the system from prompting you with problem by using the 'On Error Resume Next'. Remove that and handle the error like this. I believe it is a 2501 error but am not sure.

On Error GoTo HandleErr

' Body of code

Exit_Proc:
Exit Sub
HandleErr:
Select Case Err.Number
Case 2501
Resume Exit_Proc
Case Else
End Select
Resume Exit_Proc
Resume
End Sub

It is not evident why you are having the error but if you place a breakpoint on the select case to stop the processing you can move the processing to the 'Resume' line and press F8 to get right to where the error is occuring and then use debugging techniques to determine what is the cause of the error.

-------------------------------------
scking@arinc.com
Try to resolve problems independently
Then seek help among peers or experts
But TEST recommended solutions
-------------------------------------
 
I am not getting an error message of any sort, the button just does not work anymore until I go out of the database close, it and come back in. The it works fine again. I will do what you suggest, and hope that it works.

Thanks BLB
Always Grateful
 
You must have missed it in my first post. Buttons always work, but if you have them ignore the errors, as you have done it will skip right over them and you will not see any errors. If you want to determine what the error is that is causing it to not work then remove the 'On Error Resume Next' line and follow the instructions in the previous post.
-------------------------------------
scking@arinc.com
Try to resolve problems independently
Then seek help among peers or experts
But TEST recommended solutions
-------------------------------------
 
I remove the error message and I am following your previous post and it's not finding anything yet. But I will continue to solve the problem. BLB
Always Grateful
 
BLBurden,

I used the code described at the below attached link to create a button to send email messages in Access97 and again in Access2000 and mine works great. Of course I modified it to my particular specifications, but I'm sure if you review the code, you might find out why your command button does not always work.


Hope this helps. Who takes 7 seconds to develop,
7 mins to document,
7 hours to test,
7 months to fix will always blame the clock. s-)
 
Brenda,
When you said you removed the error message did you mean that you removed these lines of code:
'Prevent error screen if user cancels without sending mail.
On Error Resume Next

Because the On Error statement is keeping you from seeing the error message that would give you a hint as to what the problem is. You see when you say Resume Next it just executes the next line of code from your SendObjects command, which would be the End Sub.

Private Sub Command222_Click()
'Prevent error screen if user cancels without sending mail.
'On Error Resume Next
Dim strToWhom As String
Dim strMsgBody As String
Dim strManagers As String
Stop 'Use F8 key to walk through code one line at a time
'Check the values of all of your variables and controls at execution time by using the DeBug window
strToWhom = Me!Managers
strMsgBody = strMsgBody & "SIPP# " & Me.ID & " for " & Me.Company & ", will start on " & Me.Start_Date & ". Please see attachment."

DoCmd.SendObject , , , strToWhom, Me.Project_Owner, , "SIPP's ", _
strMsgBody, True
End Sub

Let's identify the error first of all and let's make sure that the values in your controls and variables are what you think they are.
Bob Scriver
 
Yes Bob, I meant I removed those two line codes: I will try what you say, if I don't get it I will just let it go. Thanks BLB[elephant2]
Always Grateful
 
Brenda, check out thread thread702-304121 . As you read down you will see that there is a know problem with ACCESS 2000 and 97 that is know to MS and there is a link to an explaination of the problem. It deals with SendObject only working the first time.

This may be your situation. The Spartans and your Texas team are on a collision course for Sunday. Go Spartans!!! Bob Scriver
 
You are a dear Bob, I did read this thread before and tried it, but because I am not an expert of code writing or adavce in it as it metion in the MS link, I sort of strayed away from it. But as I said in the earlier post it is not big deal, I just have to close the database and come back in and it works ok.

Thanks for all you much appreciated help. Well I am back off t networkign my computer, I am trying now to make my internet work from all computer.

Much Love, Peace and Harmony BLB[elephant2]
Always Grateful
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top