Conditional Message

josros60

Registered User.
Local time
Today, 13:28
Joined
Mar 10, 2011
Messages
73
i have this code for some reason never put the message even if the checkbox is checked,

would you please help me in what i need to change in order for it to work:

here it's the code:

Code:
If txtBody >= 0 Then
sBody = Me.txtBody
Else
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,"
 
 Else
 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 & "If you pay by wire, please note our bank information for wire is updated" & vbCrLf & vbCrLf & "Please contact me if you have any questions.Thanks,"
End If


'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,"


End If

This line never work:

Code:
Else
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,"

Thank you.
 
Set a breakpoint and see what txtBody has in it. Maybe it's never failing the test (particularly with the "="). I'd use:

If Len(Me.txtBody & vbNullString) > 0 Then
 
You start out by saying

If txtBody >= 0 Then

which indicates that txtBody is a Number Datatype. Then you say

sBody = Me.txtBody

which, in turns, indicates that sBody is also Numeric. But then you say

sBody = "Hi" & " " & Me.txtFirstName & "," & vbCrLf & vbCrLf & "...

which now indicates that sBody is Text!

You need to get this straight, as I believe, using the syntax for the test that Paul suggested.

Linq ;0)>
 
I did try the Paul's suggestion but still didn't work.


here the code:

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

 Else
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,"

Else
 
 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,"

thanks
 
Presumably there's more. Did you try the breakpoint to see what [Auto Collect] contains? Can you attach the db here?
 
Where, for instance, is Msgbox invoked?

Where, exactly, is this code placed?

Linq ;0)>
 
i tried to upload it but it won't let me.

can you tell how to do breakpoint, i am new in vba so i don't know yet how to do it.

I will try to upload the file later from home later.

thanks so much for your help.
 
i did a breakpoint when click send goes to the code highlight in yellow this line:

Code:
If Len(Me.txtBody & vbNullString) > 0 Then
 
At that point you can hover over values to see what they contain, or use "?" in the Immediate window, as described by the link. You can hit F8 to go to the next line, or F5 to run the code from there.
 

Users who are viewing this thread

Back
Top Bottom