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
  #1  
Old November 6th, 2006, 10:21 PM posted to microsoft.public.access.forms
Shifu
external usenet poster
 
Posts: 14
Default Runtime error 2001 (sending email)

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!

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

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!



  #3  
Old November 7th, 2006, 03:09 PM posted to microsoft.public.access.forms
Shifu
external usenet poster
 
Posts: 14
Default Runtime error 2001 (sending email)

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!


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

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!




  #5  
Old November 7th, 2006, 09:29 PM posted to microsoft.public.access.forms
Shifu
external usenet poster
 
Posts: 14
Default Runtime error 2001 (sending email)

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!



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

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!





  #7  
Old November 8th, 2006, 11:10 AM posted to microsoft.public.access.forms
Shifu
external usenet poster
 
Posts: 14
Default Runtime error 2001 (sending email)

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!




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

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!






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

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!





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

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!







 




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 11:30 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.