Conditional Code

josros60

Registered User.
Local time
Today, 06:40
Joined
Mar 10, 2011
Messages
73
I have this code, but I don't know why works somtimes and sometimes doesn't

for example, is if auto collect is checked, should pick "as per your instructions" if not the other message,

but doesn't work all the time, any idea?

thanks

Code:

Code:
If Me.txtBody > 0 Then
'If Len(Me.txtBody & vbNullString) > 0 Then
sBody = Me.txtBody


ElseIf Forms![Contact Details]![Auto Collect] = True Then
 
sBody = "Hi" & " " & Me.txtFirstName & "," & vbCrLf & vbCrLf & "Here is the monthly invoice # for " & Me.txtCompany.Column(1) & "." & " " & " As per your instructions we will withdraw the amount from your loading wallet.  " & vbCrLf & vbCrLf & "" & "Please contact me if you have any questions.Thanks,"

Else
 
sBody = "Hi" & " " & Me.txtFirstName & "," & vbCrLf & vbCrLf & "Here is the monthly invoice # for " & Me.txtCompany.Column(1) & "." & " " & "advise us if you would prefer to wire us payment to our updated SVB USD Bank account shown on the invoice, or if we may collect the payment from  your Wallet account. " & vbCrLf & vbCrLf & "" & "Please contact me if you have any questions.Thanks,"
 
 
 
 'sBody = "Hi" & " " & Me.txtFirstName & "," & vbCrLf & vbCrLf & "Here is the monthly invoice # for " & Me.txtCompany.Column(1) & "." & " " & "Please confirm if we may collect the payment from your wallet. " & vbCrLf & vbCrLf & "" & "Please contact me if you have any questions.Thanks,"
    
   End If
   If Len(Me.txtAttachment) > 0 Then
        oEmail.Attachments.Add Me.txtAttachment.Value
        
    End If

thanks again for your wonderful help.
 
put the test on autocollect first on your If...ElseIf statement.
 
Do you mean to change the code sequence:

here it's the code right now:

Code:
If Me.txtBody > 0 Then
'If Len(Me.txtBody & vbNullString) > 0 Then
sBody = Me.txtBody


ElseIf Forms![Contact Details]![Auto Collect] = True Then
 
sBody = "Hi" & " " & Me.txtFirstName & "," & vbCrLf & vbCrLf & "Here is the monthly invoice # for " & Me.txtCompany.Column(1) & "." & " " & " As per your instructions we will withdraw the amount from your loading wallet.  " & vbCrLf & vbCrLf & "" & "Please contact me if you have any questions.Thanks,"

Else
 
sBody = "Hi" & " " & Me.txtFirstName & "," & vbCrLf & vbCrLf & "Here is the monthly invoice # for " & Me.txtCompany.Column(1) & "." & " " & "advise us if you would prefer to wire us payment to our updated <b> SVB USD Bank </b> account shown on the invoice, or if we may collect the payment from  your Wallet account. " & vbCrLf & vbCrLf & "" & "Please contact me if you have any questions.Thanks,"
 
 
 
 'sBody = "Hi" & " " & Me.txtFirstName & "," & vbCrLf & vbCrLf & "Here is the monthly invoice # for " & Me.txtCompany.Column(1) & "." & " " & "Please confirm if we may collect the payment from your wallet. " & vbCrLf & vbCrLf & "" & "Please contact me if you have any questions.Thanks,"
    
   End If

sorry, can you show me what you meant, please.

I will appreciated very much.
 
yes, put it first in the condition:
Code:
If [COLOR=Blue]Forms![Contact Details]![Auto Collect] = True[/COLOR] Then
'If Len(Me.txtBody & vbNullString) > 0 Then
sBody = Me.txtBody


ElseIf [COLOR=Blue]Trim(Me.txtBody & "")) <> "" [/COLOR]Then
 
sBody = "Hi" & " " & Me.txtFirstName & "," & vbCrLf & vbCrLf & "Here is the monthly invoice # for " & Me.txtCompany.Column(1) & "." & " " & " As per your instructions we will withdraw the amount from your loading wallet.  " & vbCrLf & vbCrLf & "" & "Please contact me if you have any questions.Thanks,"

Else
 
sBody = "Hi" & " " & Me.txtFirstName & "," & vbCrLf & vbCrLf & "Here is the monthly invoice # for " & Me.txtCompany.Column(1) & "." & " " & "advise us if you would prefer to wire us payment to our updated <b> SVB USD Bank </b> account shown on the invoice, or if we may collect the payment from  your Wallet account. " & vbCrLf & vbCrLf & "" & "Please contact me if you have any questions.Thanks,"
 
 
 
 'sBody = "Hi" & " " & Me.txtFirstName & "," & vbCrLf & vbCrLf & "Here is the monthly invoice # for " & Me.txtCompany.Column(1) & "." & " " & "Please confirm if we may collect the payment from your wallet. " & vbCrLf & vbCrLf & "" & "Please contact me if you have any questions.Thanks,"
    
End If
 
Code:
If Forms![Contact Details]![Auto Collect] = True Then

sBody = "Hi" & " " & Me.txtFirstName & "," & vbCrLf & vbCrLf & "Here is the monthly invoice # for " & Me.txtCompany.Column(1) & "." & " " & " As per your instructions we will withdraw the amount from your loading wallet.  " & vbCrLf & vbCrLf & "" & "Please contact me if you have any questions.Thanks,"


ElseIf trim(Me.txtBody & "") <> "" Then
'If Len(Me.txtBody & vbNullString) > 0 Then
sBody = Me.txtBody 

Else
 
sBody = "Hi" & " " & Me.txtFirstName & "," & vbCrLf & vbCrLf & "Here is the monthly invoice # for " & Me.txtCompany.Column(1) & "." & " " & "advise us if you would prefer to wire us payment to our updated <b> SVB USD Bank </b> account shown on the invoice, or if we may collect the payment from  your Wallet account. " & vbCrLf & vbCrLf & "" & "Please contact me if you have any questions.Thanks,"
 
 
 
 'sBody = "Hi" & " " & Me.txtFirstName & "," & vbCrLf & vbCrLf & "Here is the monthly invoice # for " & Me.txtCompany.Column(1) & "." & " " & "Please confirm if we may collect the payment from your wallet. " & vbCrLf & vbCrLf & "" & "Please contact me if you have any questions.Thanks,"
    
End If
 

Users who are viewing this thread

Back
Top Bottom