A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Runtime error 2001 (sending email)



 
 
Thread Tools Display Modes
  #21  
Old November 8th, 2006, 08:35 PM posted to microsoft.public.access.forms
Shifu
external usenet poster
 
Posts: 14
Default Runtime error 2001 (sending email)

I use a danish version. That's why I don't always understand the
meaning.
But Yes, - Kunde Nr is/have a lookup field (textbox)
No combo box!

Douglas J. Steele skrev:
When you open the table and put your cursor into the Kunde Nr field, does a
combo box appear?

To check for lookup fields, open the table in Design mode, and select the
Kunde Nr. Look at the bottom left of the form that appears. Switch to the
Lookup tab. If it's got something there, you've got a lookup field.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Shifu" wrote in message
ups.com...
What is actually a lookup field and how can I check it?
Everything is create manualy. No wizard is used.
I made a copy from somewhere on the internet and just correct it to fit
with my DB.

I've tryed the debug on varTo :
varTo = DLookup("[Mail]", "[Kunde]", stWhere)
Debug.Print varTo
It came out emty in the immediate window
Don't know if you can use that to anything.


Douglas J. Steele skrev:
But Kunde Nr is a numeric field: you proved this by the fact that
DLookup("[Mail]", "[Kunde]", "[Kunde Nr] =5") worked!

Is Kunde Nr a lookup field? (i.e.: did you use the Lookup Field wizard to
create it?) This is one of the reasons why most of us vehemently dislike
lookup fields: they don't store what you think they do.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Shifu" wrote in message
ups.com...
I will remember copy-and-paste next time, if any.

In the immediate window shows [Kunde Nr] = Jane
And this is the right name from the record, I wil send mail to.




Douglas J. Steele skrev:
It's generally a good idea to copy-and-paste, rather than retyping...

Okay, perhaps stWho doesn't contain what you think it does.

Add a Debug statement in your code:

stWhere = "[Kunde Nr] = " & stWho
Debug.Print stWhere
varTo = DLookup("[Mail]", "[Kunde]", stWhere)

Once you've invoked the code, go to the Immediate window (Ctrl-G) and
see
what it's printed there.


--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Shifu" wrote in message
ps.com...
Yes and it still "[Kunde Nr] =". I just forget to change it here,
(done
now). I don't make it any easyer, I guess. Sorry Douglas


Douglas J. Steele skrev:
You said you used the following in the Immediate window:

?DLookup("[Mail]", "[Kunde]", "[Kunde Nr] =5")

However, your code is:

stWhere = "Kunde_Nr = " & stWho

Change that to:

stWhere = "[Kunde Nr] = " & stWho


--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Shifu" wrote in message
ups.com...
Ahhh sorry.
I guess this is what you mean...

Private Sub Send_Rapport_Click()
'On Error GoTo Err_Send_Rapport_Click

Dim stDocName As String
Dim stWhere As String
Dim varTo As Variant
Dim stWho As String


stWho = Me.Fornavn
stWhere = "[Kunde Nr] = " & stWho
'-- Looks up email address from Kunde
varTo = DLookup("[Mail]", "[Kunde]", stWhere) - this line
is
markt

stDocName = "Detalje Rapport"
'Write the e-mail content for sending to assignee
DoCmd.SendObject , acFormatHTML, varTo, , , acReport,
stDocName,
,
-1


Exit_Send_Rapport_Click:
Exit Sub

'Err_Send_Rapport_Click:
' MsgBox Err.Description
' Resume Exit_Send_Rapport_Click

End Sub


Douglas J. Steele skrev:
This whole thread started because you had code in
Send_Rapport_Click
that
was raising an error.

Since then, you've (presumably) made changes to that code, based
on
our
discussion. What's the code now (and what line raises the
error)?

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Shifu" wrote in message
ps.com...
Sorry Douglas!
I don't know what you mean with, "what's the actual code I've
using
now that's failing".

Douglas J. Steele skrev:
That means that DLookup is okay with the names you're using,
so
as
long
as
they're identical in your code, it should work.

What's the actual code you've using now that's failing?

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Shifu" wrote in message
oups.com...
I have try 2 [Kunde Nr]= 4 and 5
The message underneath ?DLookup("[Mail]", "[Kunde]",
"[Kunde
Nr]
=5")
is the email address from the db record. This is correct.
Does the above make any sence to you?

Douglas J. Steele skrev:
Type the line, then hit Enter. The result should appear
underneath
what
you've typed (or else an error message will pop up)

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Shifu" wrote in message
oups.com...
varTo = DLookup("[Mail]", "[Kunde]", stWhere) didn't do
it.

I put the line ?DLookup("[Mail]", "[Kunde]", "[Kunde Nr]
=145")
in
the
Immediate window, but how do I run it from there? The
only
thing
I
can
run is macro, for what I can see.


Douglas J. Steele skrev:
See whether putting square brackets around the names of
the
fields
and
table
helps:

DLookup("[Mail]", "[Kunde]", stWhere)

If not, go to the Immediate window (Ctrl-G) and try
running
the
DLookup
there. You'll need to precede the call with a question
mark:

?DLookup("[Mail]", "[Kunde]", "[Kunde Nr] = 5")

(or whatever value you're currently trying to use for
Kunde
Nr)

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"Shifu" wrote in message
oups.com...
Kunde Nr was numeric and I change the line, but it
didn't
help.
I allso change (Email) to (Mail). Same error...

Here is my table var:
It's in danish, therefore the translation (text) etc.

Tablename = Kunde
Kunde Nr - Tal (Numeric) =Key
Fornavn - Tekst (Text)
Mail - Tekst (Text)
...and some others...

The above is what I use. I try to activate the send
mail
from
"Kunde -
formular". I just can't see where I mistype. Maby
it's
simple,
but
not
for me.

Hope you don't give up on me. But if you do, thanks
for
trying!

Douglas J. Steele skrev:
You're positive you haven't mistyped the name of the
table
(Kunde)
or
the
name of either of the fields (EMail and Kunde Nr)?

Also, what you've got assumes that Kunde Nr is a
text
field.
If
it's
actually numeric, use

stWhere = "[Kunde Nr] = " & stWho


--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Shifu" wrote in message
ps.com...
Hey Douglas!

I'm emty, blank, run out of tears...

I change the line, but the message, "error 2001",
are
still
showing.
Allso [Kunde].[Kunde Nr] did not helt.
Would it helt if you can see the table?

Any other suggestion?


Douglas J. Steele skrev:
That very misleading error message can occur when
you've
made
a
mistake
typing the name of the table or field in DLookup
functions.
In
your
case,
your reference to the field in the Where clause
is
incorrect.
Try
changing

stWhere = "[Kunde.Kunde Nr] = " & "'" & stWho &
"'"

to

stWhere = "[Kunde Nr] = " & "'" & stWho & "'"

(Since you can only have a single domain in
DLookup,
there's
no
need
to
qualify the field. When you do need to refer to
both
the
table
and
field,
such as in an SQL statement, it would be
[Kunde].[Kunde
Nr])

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Shifu" wrote in message
ups.com...
Hey There!
Is there anyboddy who can help me?

I try to send a mail via Access. This is my
code:
-------------------------------------------------
Private Sub Send_Rapport_Click()
On Error GoTo Err_Send_Rapport_Click

Dim stDocName As String
Dim stWhere As String
Dim varTo As Variant
Dim stWho As String

stWho = Me.Fornavn
stWhere = "[Kunde.Kunde Nr] = " & "'" &
stWho &
"'"
'-- Looks up email address from TblUsers
varTo = DLookup("EMail", "Kunde", stWhere)
'--
this
line
is
markt

stDocName = "Detalje Rapport"
'Write the e-mail content for sending to
assignee
DoCmd.SendObject , acFormatHTML, varTo, , ,
acReport,
stDocName,
,
-1


Exit_Send_Rapport_Click:
Exit Sub

Err_Send_Rapport_Click:
MsgBox Err.Description
Resume Exit_Send_Rapport_Click

End Sub
---------------------------------------
I just can't see where I do it wrong. But I
keep
on
getting
the
runtime
error 2001 - You cancelled the previous
operation??

Please helt .. anyone!











  #22  
Old November 8th, 2006, 10:22 PM posted to microsoft.public.access.forms
Douglas J. Steele
external usenet poster
 
Posts: 9,313
Default Runtime error 2001 (sending email)

Where does Fornavn get its value from?

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"Shifu" wrote in message
ups.com...
I use a danish version. That's why I don't always understand the
meaning.
But Yes, - Kunde Nr is/have a lookup field (textbox)
No combo box!

Douglas J. Steele skrev:
When you open the table and put your cursor into the Kunde Nr field, does
a
combo box appear?

To check for lookup fields, open the table in Design mode, and select the
Kunde Nr. Look at the bottom left of the form that appears. Switch to the
Lookup tab. If it's got something there, you've got a lookup field.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Shifu" wrote in message
ups.com...
What is actually a lookup field and how can I check it?
Everything is create manualy. No wizard is used.
I made a copy from somewhere on the internet and just correct it to fit
with my DB.

I've tryed the debug on varTo :
varTo = DLookup("[Mail]", "[Kunde]", stWhere)
Debug.Print varTo
It came out emty in the immediate window
Don't know if you can use that to anything.


Douglas J. Steele skrev:
But Kunde Nr is a numeric field: you proved this by the fact that
DLookup("[Mail]", "[Kunde]", "[Kunde Nr] =5") worked!

Is Kunde Nr a lookup field? (i.e.: did you use the Lookup Field wizard
to
create it?) This is one of the reasons why most of us vehemently
dislike
lookup fields: they don't store what you think they do.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Shifu" wrote in message
ups.com...
I will remember copy-and-paste next time, if any.

In the immediate window shows [Kunde Nr] = Jane
And this is the right name from the record, I wil send mail to.




Douglas J. Steele skrev:
It's generally a good idea to copy-and-paste, rather than
retyping...

Okay, perhaps stWho doesn't contain what you think it does.

Add a Debug statement in your code:

stWhere = "[Kunde Nr] = " & stWho
Debug.Print stWhere
varTo = DLookup("[Mail]", "[Kunde]", stWhere)

Once you've invoked the code, go to the Immediate window (Ctrl-G)
and
see
what it's printed there.


--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Shifu" wrote in message
ps.com...
Yes and it still "[Kunde Nr] =". I just forget to change it here,
(done
now). I don't make it any easyer, I guess. Sorry Douglas


Douglas J. Steele skrev:
You said you used the following in the Immediate window:

?DLookup("[Mail]", "[Kunde]", "[Kunde Nr] =5")

However, your code is:

stWhere = "Kunde_Nr = " & stWho

Change that to:

stWhere = "[Kunde Nr] = " & stWho


--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Shifu" wrote in message
ups.com...
Ahhh sorry.
I guess this is what you mean...

Private Sub Send_Rapport_Click()
'On Error GoTo Err_Send_Rapport_Click

Dim stDocName As String
Dim stWhere As String
Dim varTo As Variant
Dim stWho As String


stWho = Me.Fornavn
stWhere = "[Kunde Nr] = " & stWho
'-- Looks up email address from Kunde
varTo = DLookup("[Mail]", "[Kunde]", stWhere) - this
line
is
markt

stDocName = "Detalje Rapport"
'Write the e-mail content for sending to assignee
DoCmd.SendObject , acFormatHTML, varTo, , , acReport,
stDocName,
,
-1


Exit_Send_Rapport_Click:
Exit Sub

'Err_Send_Rapport_Click:
' MsgBox Err.Description
' Resume Exit_Send_Rapport_Click

End Sub


Douglas J. Steele skrev:
This whole thread started because you had code in
Send_Rapport_Click
that
was raising an error.

Since then, you've (presumably) made changes to that code,
based
on
our
discussion. What's the code now (and what line raises the
error)?

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Shifu" wrote in message
ps.com...
Sorry Douglas!
I don't know what you mean with, "what's the actual code
I've
using
now that's failing".

Douglas J. Steele skrev:
That means that DLookup is okay with the names you're
using,
so
as
long
as
they're identical in your code, it should work.

What's the actual code you've using now that's failing?

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Shifu" wrote in message
oups.com...
I have try 2 [Kunde Nr]= 4 and 5
The message underneath ?DLookup("[Mail]", "[Kunde]",
"[Kunde
Nr]
=5")
is the email address from the db record. This is
correct.
Does the above make any sence to you?

Douglas J. Steele skrev:
Type the line, then hit Enter. The result should appear
underneath
what
you've typed (or else an error message will pop up)

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Shifu" wrote in message
oups.com...
varTo = DLookup("[Mail]", "[Kunde]", stWhere) didn't
do
it.

I put the line ?DLookup("[Mail]", "[Kunde]", "[Kunde
Nr]
=145")
in
the
Immediate window, but how do I run it from there? The
only
thing
I
can
run is macro, for what I can see.


Douglas J. Steele skrev:
See whether putting square brackets around the names
of
the
fields
and
table
helps:

DLookup("[Mail]", "[Kunde]", stWhere)

If not, go to the Immediate window (Ctrl-G) and try
running
the
DLookup
there. You'll need to precede the call with a
question
mark:

?DLookup("[Mail]", "[Kunde]", "[Kunde Nr] = 5")

(or whatever value you're currently trying to use
for
Kunde
Nr)

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"Shifu" wrote in message
oups.com...
Kunde Nr was numeric and I change the line, but it
didn't
help.
I allso change (Email) to (Mail). Same error...

Here is my table var:
It's in danish, therefore the translation (text)
etc.

Tablename = Kunde
Kunde Nr - Tal (Numeric) =Key
Fornavn - Tekst (Text)
Mail - Tekst (Text)
...and some others...

The above is what I use. I try to activate the
send
mail
from
"Kunde -
formular". I just can't see where I mistype. Maby
it's
simple,
but
not
for me.

Hope you don't give up on me. But if you do,
thanks
for
trying!

Douglas J. Steele skrev:
You're positive you haven't mistyped the name of
the
table
(Kunde)
or
the
name of either of the fields (EMail and Kunde
Nr)?

Also, what you've got assumes that Kunde Nr is a
text
field.
If
it's
actually numeric, use

stWhere = "[Kunde Nr] = " & stWho


--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Shifu" wrote in message
ps.com...
Hey Douglas!

I'm emty, blank, run out of tears...

I change the line, but the message, "error
2001",
are
still
showing.
Allso [Kunde].[Kunde Nr] did not helt.
Would it helt if you can see the table?

Any other suggestion?


Douglas J. Steele skrev:
That very misleading error message can occur
when
you've
made
a
mistake
typing the name of the table or field in
DLookup
functions.
In
your
case,
your reference to the field in the Where
clause
is
incorrect.
Try
changing

stWhere = "[Kunde.Kunde Nr] = " & "'" & stWho
&
"'"

to

stWhere = "[Kunde Nr] = " & "'" & stWho & "'"

(Since you can only have a single domain in
DLookup,
there's
no
need
to
qualify the field. When you do need to refer
to
both
the
table
and
field,
such as in an SQL statement, it would be
[Kunde].[Kunde
Nr])

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Shifu" wrote in message
ups.com...
Hey There!
Is there anyboddy who can help me?

I try to send a mail via Access. This is my
code:
-------------------------------------------------
Private Sub Send_Rapport_Click()
On Error GoTo Err_Send_Rapport_Click

Dim stDocName As String
Dim stWhere As String
Dim varTo As Variant
Dim stWho As String

stWho = Me.Fornavn
stWhere = "[Kunde.Kunde Nr] = " & "'" &
stWho &
"'"
'-- Looks up email address from TblUsers
varTo = DLookup("EMail", "Kunde",
stWhere)
'--
this
line
is
markt

stDocName = "Detalje Rapport"
'Write the e-mail content for sending to
assignee
DoCmd.SendObject , acFormatHTML, varTo, ,
,
acReport,
stDocName,
,
-1


Exit_Send_Rapport_Click:
Exit Sub

Err_Send_Rapport_Click:
MsgBox Err.Description
Resume Exit_Send_Rapport_Click

End Sub
---------------------------------------
I just can't see where I do it wrong. But I
keep
on
getting
the
runtime
error 2001 - You cancelled the previous
operation??

Please helt .. anyone!













  #23  
Old November 9th, 2006, 12:33 AM posted to microsoft.public.access.forms
Shifu
external usenet poster
 
Posts: 14
Default Runtime error 2001 (sending email)

From [Kunde], if that's what you mean?

Douglas J. Steele skrev:
Where does Fornavn get its value from?

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"Shifu" wrote in message
ups.com...
I use a danish version. That's why I don't always understand the
meaning.
But Yes, - Kunde Nr is/have a lookup field (textbox)
No combo box!

Douglas J. Steele skrev:
When you open the table and put your cursor into the Kunde Nr field, does
a
combo box appear?

To check for lookup fields, open the table in Design mode, and select the
Kunde Nr. Look at the bottom left of the form that appears. Switch to the
Lookup tab. If it's got something there, you've got a lookup field.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Shifu" wrote in message
ups.com...
What is actually a lookup field and how can I check it?
Everything is create manualy. No wizard is used.
I made a copy from somewhere on the internet and just correct it to fit
with my DB.

I've tryed the debug on varTo :
varTo = DLookup("[Mail]", "[Kunde]", stWhere)
Debug.Print varTo
It came out emty in the immediate window
Don't know if you can use that to anything.


Douglas J. Steele skrev:
But Kunde Nr is a numeric field: you proved this by the fact that
DLookup("[Mail]", "[Kunde]", "[Kunde Nr] =5") worked!

Is Kunde Nr a lookup field? (i.e.: did you use the Lookup Field wizard
to
create it?) This is one of the reasons why most of us vehemently
dislike
lookup fields: they don't store what you think they do.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Shifu" wrote in message
ups.com...
I will remember copy-and-paste next time, if any.

In the immediate window shows [Kunde Nr] = Jane
And this is the right name from the record, I wil send mail to.




Douglas J. Steele skrev:
It's generally a good idea to copy-and-paste, rather than
retyping...

Okay, perhaps stWho doesn't contain what you think it does.

Add a Debug statement in your code:

stWhere = "[Kunde Nr] = " & stWho
Debug.Print stWhere
varTo = DLookup("[Mail]", "[Kunde]", stWhere)

Once you've invoked the code, go to the Immediate window (Ctrl-G)
and
see
what it's printed there.


--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Shifu" wrote in message
ps.com...
Yes and it still "[Kunde Nr] =". I just forget to change it here,
(done
now). I don't make it any easyer, I guess. Sorry Douglas


Douglas J. Steele skrev:
You said you used the following in the Immediate window:

?DLookup("[Mail]", "[Kunde]", "[Kunde Nr] =5")

However, your code is:

stWhere = "Kunde_Nr = " & stWho

Change that to:

stWhere = "[Kunde Nr] = " & stWho


--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Shifu" wrote in message
ups.com...
Ahhh sorry.
I guess this is what you mean...

Private Sub Send_Rapport_Click()
'On Error GoTo Err_Send_Rapport_Click

Dim stDocName As String
Dim stWhere As String
Dim varTo As Variant
Dim stWho As String


stWho = Me.Fornavn
stWhere = "[Kunde Nr] = " & stWho
'-- Looks up email address from Kunde
varTo = DLookup("[Mail]", "[Kunde]", stWhere) - this
line
is
markt

stDocName = "Detalje Rapport"
'Write the e-mail content for sending to assignee
DoCmd.SendObject , acFormatHTML, varTo, , , acReport,
stDocName,
,
-1


Exit_Send_Rapport_Click:
Exit Sub

'Err_Send_Rapport_Click:
' MsgBox Err.Description
' Resume Exit_Send_Rapport_Click

End Sub


Douglas J. Steele skrev:
This whole thread started because you had code in
Send_Rapport_Click
that
was raising an error.

Since then, you've (presumably) made changes to that code,
based
on
our
discussion. What's the code now (and what line raises the
error)?

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Shifu" wrote in message
ps.com...
Sorry Douglas!
I don't know what you mean with, "what's the actual code
I've
using
now that's failing".

Douglas J. Steele skrev:
That means that DLookup is okay with the names you're
using,
so
as
long
as
they're identical in your code, it should work.

What's the actual code you've using now that's failing?

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Shifu" wrote in message
oups.com...
I have try 2 [Kunde Nr]= 4 and 5
The message underneath ?DLookup("[Mail]", "[Kunde]",
"[Kunde
Nr]
=5")
is the email address from the db record. This is
correct.
Does the above make any sence to you?

Douglas J. Steele skrev:
Type the line, then hit Enter. The result should appear
underneath
what
you've typed (or else an error message will pop up)

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Shifu" wrote in message
oups.com...
varTo = DLookup("[Mail]", "[Kunde]", stWhere) didn't
do
it.

I put the line ?DLookup("[Mail]", "[Kunde]", "[Kunde
Nr]
=145")
in
the
Immediate window, but how do I run it from there? The
only
thing
I
can
run is macro, for what I can see.


Douglas J. Steele skrev:
See whether putting square brackets around the names
of
the
fields
and
table
helps:

DLookup("[Mail]", "[Kunde]", stWhere)

If not, go to the Immediate window (Ctrl-G) and try
running
the
DLookup
there. You'll need to precede the call with a
question
mark:

?DLookup("[Mail]", "[Kunde]", "[Kunde Nr] = 5")

(or whatever value you're currently trying to use
for
Kunde
Nr)

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"Shifu" wrote in message
oups.com...
Kunde Nr was numeric and I change the line, but it
didn't
help.
I allso change (Email) to (Mail). Same error...

Here is my table var:
It's in danish, therefore the translation (text)
etc.

Tablename = Kunde
Kunde Nr - Tal (Numeric) =Key
Fornavn - Tekst (Text)
Mail - Tekst (Text)
...and some others...

The above is what I use. I try to activate the
send
mail
from
"Kunde -
formular". I just can't see where I mistype. Maby
it's
simple,
but
not
for me.

Hope you don't give up on me. But if you do,
thanks
for
trying!

Douglas J. Steele skrev:
You're positive you haven't mistyped the name of
the
table
(Kunde)
or
the
name of either of the fields (EMail and Kunde
Nr)?

Also, what you've got assumes that Kunde Nr is a
text
field.
If
it's
actually numeric, use

stWhere = "[Kunde Nr] = " & stWho


--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Shifu" wrote in message
ps.com...
Hey Douglas!

I'm emty, blank, run out of tears...

I change the line, but the message, "error
2001",
are
still
showing.
Allso [Kunde].[Kunde Nr] did not helt.
Would it helt if you can see the table?

Any other suggestion?


Douglas J. Steele skrev:
That very misleading error message can occur
when
you've
made
a
mistake
typing the name of the table or field in
DLookup
functions.
In
your
case,
your reference to the field in the Where
clause
is
incorrect.
Try
changing

stWhere = "[Kunde.Kunde Nr] = " & "'" & stWho
&
"'"

to

stWhere = "[Kunde Nr] = " & "'" & stWho & "'"

(Since you can only have a single domain in
DLookup,
there's
no
need
to
qualify the field. When you do need to refer
to
both
the
table
and
field,
such as in an SQL statement, it would be
[Kunde].[Kunde
Nr])

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Shifu" wrote in message
ups.com...
Hey There!
Is there anyboddy who can help me?

I try to send a mail via Access. This is my
code:
-------------------------------------------------
Private Sub Send_Rapport_Click()
On Error GoTo Err_Send_Rapport_Click

Dim stDocName As String
Dim stWhere As String
Dim varTo As Variant
Dim stWho As String

stWho = Me.Fornavn
stWhere = "[Kunde.Kunde Nr] = " & "'" &
stWho &
"'"
'-- Looks up email address from TblUsers
varTo = DLookup("EMail", "Kunde",
stWhere)
'--
this
line
is
markt

stDocName = "Detalje Rapport"
'Write the e-mail content for sending to
assignee
DoCmd.SendObject , acFormatHTML, varTo, ,
,
acReport,
stDocName,
,
-1


Exit_Send_Rapport_Click:
Exit Sub

Err_Send_Rapport_Click:
MsgBox Err.Description
Resume Exit_Send_Rapport_Click

End Sub
---------------------------------------
I just can't see where I do it wrong. But I
keep
on
getting
the
runtime
error 2001 - You cancelled the previous
operation??

Please helt .. anyone!












  #24  
Old November 9th, 2006, 11:52 AM posted to microsoft.public.access.forms
Douglas J. Steele
external usenet poster
 
Posts: 9,313
Default Runtime error 2001 (sending email)

Is Fornavn a separate field in Kunde, or is it the Kunde Nr field?

If there's a Fornavn field in Kunde, then change your DLookup to use that
field instead:

stWho = Me.Fornavn
stWhere = "[Fornavn] = '" & stWho & "'"
varTo = DLookup("Mail", "Kunde", stWhere)

If the text box Fornavn on your form is bound to the Kunde Nr field of your
recordset, then you've got some problems! You'll have to determine what the
number is that corresponds to the name, and use that number in your current
DLookup statement.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Shifu" wrote in message
oups.com...
From [Kunde], if that's what you mean?


Douglas J. Steele skrev:
Where does Fornavn get its value from?

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"Shifu" wrote in message
ups.com...
I use a danish version. That's why I don't always understand the
meaning.
But Yes, - Kunde Nr is/have a lookup field (textbox)
No combo box!

Douglas J. Steele skrev:
When you open the table and put your cursor into the Kunde Nr field,
does
a
combo box appear?

To check for lookup fields, open the table in Design mode, and select
the
Kunde Nr. Look at the bottom left of the form that appears. Switch to
the
Lookup tab. If it's got something there, you've got a lookup field.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Shifu" wrote in message
ups.com...
What is actually a lookup field and how can I check it?
Everything is create manualy. No wizard is used.
I made a copy from somewhere on the internet and just correct it to
fit
with my DB.

I've tryed the debug on varTo :
varTo = DLookup("[Mail]", "[Kunde]", stWhere)
Debug.Print varTo
It came out emty in the immediate window
Don't know if you can use that to anything.


Douglas J. Steele skrev:
But Kunde Nr is a numeric field: you proved this by the fact that
DLookup("[Mail]", "[Kunde]", "[Kunde Nr] =5") worked!

Is Kunde Nr a lookup field? (i.e.: did you use the Lookup Field
wizard
to
create it?) This is one of the reasons why most of us vehemently
dislike
lookup fields: they don't store what you think they do.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)



  #25  
Old November 9th, 2006, 12:58 PM posted to microsoft.public.access.forms
Shifu
external usenet poster
 
Posts: 14
Default Runtime error 2001 (sending email)

Wow!!! Now something happend.
Outlook open and the mail adress shows in the "to" field. Ready to
send.
But, there is always a but. Some of the record returns a NULL in varTo
And the "To" field in Outlook is emty.
I use Debug.Print varTo
Any ide why?

Both fields are separate in Kunde and none of them is bound.

Douglas J. Steele skrev:
Is Fornavn a separate field in Kunde, or is it the Kunde Nr field?

If there's a Fornavn field in Kunde, then change your DLookup to use that
field instead:

stWho = Me.Fornavn
stWhere = "[Fornavn] = '" & stWho & "'"
varTo = DLookup("Mail", "Kunde", stWhere)

If the text box Fornavn on your form is bound to the Kunde Nr field of your
recordset, then you've got some problems! You'll have to determine what the
number is that corresponds to the name, and use that number in your current
DLookup statement.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Shifu" wrote in message
oups.com...
From [Kunde], if that's what you mean?


Douglas J. Steele skrev:
Where does Fornavn get its value from?

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"Shifu" wrote in message
ups.com...
I use a danish version. That's why I don't always understand the
meaning.
But Yes, - Kunde Nr is/have a lookup field (textbox)
No combo box!

Douglas J. Steele skrev:
When you open the table and put your cursor into the Kunde Nr field,
does
a
combo box appear?

To check for lookup fields, open the table in Design mode, and select
the
Kunde Nr. Look at the bottom left of the form that appears. Switch to
the
Lookup tab. If it's got something there, you've got a lookup field.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Shifu" wrote in message
ups.com...
What is actually a lookup field and how can I check it?
Everything is create manualy. No wizard is used.
I made a copy from somewhere on the internet and just correct it to
fit
with my DB.

I've tryed the debug on varTo :
varTo = DLookup("[Mail]", "[Kunde]", stWhere)
Debug.Print varTo
It came out emty in the immediate window
Don't know if you can use that to anything.


Douglas J. Steele skrev:
But Kunde Nr is a numeric field: you proved this by the fact that
DLookup("[Mail]", "[Kunde]", "[Kunde Nr] =5") worked!

Is Kunde Nr a lookup field? (i.e.: did you use the Lookup Field
wizard
to
create it?) This is one of the reasons why most of us vehemently
dislike
lookup fields: they don't store what you think they do.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


  #26  
Old November 9th, 2006, 01:35 PM posted to microsoft.public.access.forms
Douglas J. Steele
external usenet poster
 
Posts: 9,313
Default Runtime error 2001 (sending email)

Only call SendObject when you have an e-mail address for the individual:

If Not IsNull(varTo) Then
DoCmd.SendObject , acFormatHTML, varTo, , , acReport, stDocName, ,-1
End If

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Shifu" wrote in message
ups.com...
Wow!!! Now something happend.
Outlook open and the mail adress shows in the "to" field. Ready to
send.
But, there is always a but. Some of the record returns a NULL in varTo
And the "To" field in Outlook is emty.
I use Debug.Print varTo
Any ide why?

Both fields are separate in Kunde and none of them is bound.

Douglas J. Steele skrev:
Is Fornavn a separate field in Kunde, or is it the Kunde Nr field?

If there's a Fornavn field in Kunde, then change your DLookup to use that
field instead:

stWho = Me.Fornavn
stWhere = "[Fornavn] = '" & stWho & "'"
varTo = DLookup("Mail", "Kunde", stWhere)

If the text box Fornavn on your form is bound to the Kunde Nr field of
your
recordset, then you've got some problems! You'll have to determine what
the
number is that corresponds to the name, and use that number in your
current
DLookup statement.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Shifu" wrote in message
oups.com...
From [Kunde], if that's what you mean?

Douglas J. Steele skrev:
Where does Fornavn get its value from?

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"Shifu" wrote in message
ups.com...
I use a danish version. That's why I don't always understand the
meaning.
But Yes, - Kunde Nr is/have a lookup field (textbox)
No combo box!

Douglas J. Steele skrev:
When you open the table and put your cursor into the Kunde Nr
field,
does
a
combo box appear?

To check for lookup fields, open the table in Design mode, and
select
the
Kunde Nr. Look at the bottom left of the form that appears. Switch
to
the
Lookup tab. If it's got something there, you've got a lookup field.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Shifu" wrote in message
ups.com...
What is actually a lookup field and how can I check it?
Everything is create manualy. No wizard is used.
I made a copy from somewhere on the internet and just correct it
to
fit
with my DB.

I've tryed the debug on varTo :
varTo = DLookup("[Mail]", "[Kunde]", stWhere)
Debug.Print varTo
It came out emty in the immediate window
Don't know if you can use that to anything.


Douglas J. Steele skrev:
But Kunde Nr is a numeric field: you proved this by the fact
that
DLookup("[Mail]", "[Kunde]", "[Kunde Nr] =5") worked!

Is Kunde Nr a lookup field? (i.e.: did you use the Lookup Field
wizard
to
create it?) This is one of the reasons why most of us vehemently
dislike
lookup fields: they don't store what you think they do.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)




  #27  
Old November 9th, 2006, 02:01 PM posted to microsoft.public.access.forms
Shifu
external usenet poster
 
Posts: 14
Default Runtime error 2001 (sending email)

I owe you one or more! If there is anything...

Thank you so very, very mush Douglas!!

Svend


Douglas J. Steele skrev:
Only call SendObject when you have an e-mail address for the individual:

If Not IsNull(varTo) Then
DoCmd.SendObject , acFormatHTML, varTo, , , acReport, stDocName, ,-1
End If

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Shifu" wrote in message
ups.com...
Wow!!! Now something happend.
Outlook open and the mail adress shows in the "to" field. Ready to
send.
But, there is always a but. Some of the record returns a NULL in varTo
And the "To" field in Outlook is emty.
I use Debug.Print varTo
Any ide why?

Both fields are separate in Kunde and none of them is bound.

Douglas J. Steele skrev:
Is Fornavn a separate field in Kunde, or is it the Kunde Nr field?

If there's a Fornavn field in Kunde, then change your DLookup to use that
field instead:

stWho = Me.Fornavn
stWhere = "[Fornavn] = '" & stWho & "'"
varTo = DLookup("Mail", "Kunde", stWhere)

If the text box Fornavn on your form is bound to the Kunde Nr field of
your
recordset, then you've got some problems! You'll have to determine what
the
number is that corresponds to the name, and use that number in your
current
DLookup statement.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Shifu" wrote in message
oups.com...
From [Kunde], if that's what you mean?

Douglas J. Steele skrev:
Where does Fornavn get its value from?

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"Shifu" wrote in message
ups.com...
I use a danish version. That's why I don't always understand the
meaning.
But Yes, - Kunde Nr is/have a lookup field (textbox)
No combo box!

Douglas J. Steele skrev:
When you open the table and put your cursor into the Kunde Nr
field,
does
a
combo box appear?

To check for lookup fields, open the table in Design mode, and
select
the
Kunde Nr. Look at the bottom left of the form that appears. Switch
to
the
Lookup tab. If it's got something there, you've got a lookup field.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Shifu" wrote in message
ups.com...
What is actually a lookup field and how can I check it?
Everything is create manualy. No wizard is used.
I made a copy from somewhere on the internet and just correct it
to
fit
with my DB.

I've tryed the debug on varTo :
varTo = DLookup("[Mail]", "[Kunde]", stWhere)
Debug.Print varTo
It came out emty in the immediate window
Don't know if you can use that to anything.


Douglas J. Steele skrev:
But Kunde Nr is a numeric field: you proved this by the fact
that
DLookup("[Mail]", "[Kunde]", "[Kunde Nr] =5") worked!

Is Kunde Nr a lookup field? (i.e.: did you use the Lookup Field
wizard
to
create it?) This is one of the reasons why most of us vehemently
dislike
lookup fields: they don't store what you think they do.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 08:44 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.