Passing an argument from a query to a command

  • Thread starter benforum via AccessMonster.com
  • Start date
B

benforum via AccessMonster.com

I am trying to send a report using an email address in a DB. I wrote the
following code for it.
Private Sub Reminder_Letter_Command_Click()
On Error GoTo Err_Reminder_Letter_Command_Click

Dim stDocName As String
Dim SendTO As String


stDocName = "BG Reminder Letter"

RunQuery

MsgBox "This is After RunQuery " & SendTO
SendTO = [Queries]![BG email only from email from ae code].EmailAddress
MsgBox "This is SendTO 2 Value ==== " & SendTO

DoCmd.OpenReport stDocName, acViewNormal
DoCmd.SendObject acSendReport, stDocName, , SendTO



Exit_Reminder_Letter_Command_Click:
Exit Sub

Err_Reminder_Letter_Command_Click:
MsgBox Err.Description
Resume Exit_Reminder_Letter_Command_Click

End Sub

The query runs and produces the correct email address, however when I try to
put it into a string I receive an error message. The email field is defined
in the DB as text.

What am I doing wrong? How to correct the code?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top