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

Run-time error '13' Type Mismatch

Status
Not open for further replies.

mommom

Technical User
Joined
Nov 14, 2003
Messages
208
Location
US
Good Morning,

We have changed our system over from 2000 to 2003 and now I am getting a run time error on the code listed below:

Private Sub Command57_Click()
If Project1.[Form_Visit Request Form].POCEmail.Value <> "" Or Project1.[Form_Visit Request Form].POCEmail.Value <> Null Then
DocCmd.SendObject , , "HTML(*.html)", Project1.[Form_Visit Request Form].POCEmail.Value, , , "Visit Request", "Your request for " + Project1.[Form_Visit Request Form].StartDate.Value + " - " + Project1.[Form_Visit Request Form].EndDate.Value + " has been entered", 0
Else
MsgBox "POC Email Is Invalid"
End If
End Sub

Any help to resolve this would be grateful.

 
try using

if len(textVal & "") > 0 then

to test if a value is null or not...

--------------------
Procrastinate Now!
 
I'm a fan of referencing through the forms collection, and, comparisions between a control/field/... and Null isn't meaningful, one will need for instance the IsNull function (or something like the below sample).

So, say the form name as viewed in the database window is frmVisitRequestForm, here's a test combining Null and ZLS test:

[tt]if trim$(forms!frmVisitRequestForm!POCEmail.value & "") <>"" then
...[/tt]

Do the same type of form control referencing in the SendObject line - and - the concatenation operator in VB(A), is ampersand (&). Using + can sometime give challenges...

Roy-Vidar
 
Roy, the concatenation operators in VBA are & and +
The difference is in the way null values are handled:
A & B is null when BOTH A and B are null
A + B is null when EITHER A or B is null

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
PHV, here's a couple of samples of what Microsoft says about concatenation operator in VB(A)...

"Finally, notice that you use ampersand symbols (&) to concatenate strings in Visual Basic and you use plus symbols (+) to concatenate strings in C#." from Ten Code Conversions for VBA, Visual Basic .NET, and C#

"Use the ampersand for all concatenation operations; never use the plus sign (+)." from Visual Basic Programmer's Guide

"Use the ampersand character (&) instead of a plus sign (+) to concatenate strings." from Switching from WordBasic

- all from the first page of a web search

If I emphasize like this, then "Using + can sometime give challenges..." - does this indicate I'm aware or not of what you're trying to teach me;-)

(btw - have made use of the technique once or twice, too thread703-879125;-))

Roy-Vidar
 
Private Sub Command57_Click()
Good Morning Roy,

So how should I modify the below so it would work?

If Project1.[Form_Visit Request Form].POCEmail.Value <> "" Or Project1.[Form_Visit Request Form].POCEmail.Value <> Null Then
DocCmd.SendObject , , "HTML(*.html)", Project1.[Form_Visit Request Form].POCEmail.Value, , , "Visit Request", "Your request for " + Project1.[Form_Visit Request Form].StartDate.Value + " - " + Project1.[Form_Visit Request Form].EndDate.Value + " has been entered", 0
Else
MsgBox "POC Email Is Invalid"
End If
End Sub

Thanks,

Sher
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top