help with code needed

bone head

Registered User.
Local time
Today, 22:32
Joined
Feb 11, 2002
Messages
73
Hello

i have a button which automaticly sends an email when pressed to someone else within the company to authorise credit, despite text on the screen people still click the button when no credit is required, so i need to restrict this if the credit is zero

i have the code below which seems to work fine message box comes up saying no credit needed, however i need to then cancel the click action and return to the form and am not sure how to go about this.

I have left a gap in the text wher i think this should be and would be most grateful if anyone has the solution

TIA

Private Sub Command44_Click()
On Error GoTo Err_command44_Click
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

If [credit amount] < 1 Then MsgBox "no credit is required"




Dim stDocName As String
stDocName = "credit approved"

DoCmd.OpenReport stDocName, acViewPreview, , "[complaint No]=" & Forms![manager input1]![complaint No]
MsgBox "opening E-mail"
DoCmd.SendObject acReport, "credit approved", "RichTextFormat(*.rtf)", _
"e-mail;e-mail", , , "Credit Authorisation required", "A Customer Contact on the Data base requires authorisation", True

MsgBox "E-Mail has been sent"

DoCmd.Close

Exit_command44_Click:
Exit Sub

Err_command44_Click:
MsgBox Err.Description
Resume Exit_command44_Click

End Sub
 
How about:

If [credit amount] < 1 Then
MsgBox "no credit is required"
Exit sub
End if

HTH
Patrick.
 
PaddyIrishMan said:
How about:

If [credit amount] < 1 Then
MsgBox "no credit is required"
Exit sub
End if

I don't know the type of values you'll have in the table - integer, long, single, or double, so I'd suggest a minor change to PaddyIrishman's suggestion.

Code:
If [credit amount] <=0 Then 
   MsgBox "no credit is required" 
   Exit sub 
End If

Just on the off-chance there may be a value of 0.75 or something which is less than 1 but still greater than 0.
 
Many thanks, I am hhowever getting an error message when running it

Complior error " If without block if"

Inserted the following into previous code


If [credit amount] <= 0 Then MsgBox "No credit is required"
Exit Sub
End If

Any ideas what i have done wrong

Cheers
 
If [credit amount] <= 0 Then
MsgBox "No credit is required"
Exit Sub
End If

This should sort it out. (Can't have data after the "Then" with an Endif)
 
Bingo!!!!

As always it is obvious

I must learn to read excatly what i see in answers to questions

Many thanks again
 

Users who are viewing this thread

Back
Top Bottom