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. |
|
|
Thread Tools | Display Modes |
#11
|
|||
|
|||
Runtime error 2001 (sending email)
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! |
#12
|
|||
|
|||
Runtime error 2001 (sending email)
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! |
#13
|
|||
|
|||
Runtime error 2001 (sending email)
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! |
#14
|
|||
|
|||
Runtime error 2001 (sending email)
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! |
#15
|
|||
|
|||
Runtime error 2001 (sending email)
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! |
#16
|
|||
|
|||
Runtime error 2001 (sending email)
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! |
#17
|
|||
|
|||
Runtime error 2001 (sending email)
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! |
#18
|
|||
|
|||
Runtime error 2001 (sending email)
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! |
#19
|
|||
|
|||
Runtime error 2001 (sending email)
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! |
#20
|
|||
|
|||
Runtime error 2001 (sending email)
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 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 | |
|
|