Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
scliffe
Starting Member
2 Posts |
Posted - 2008-02-19 : 05:22:10
|
Hi,I've got a form that will send an e-mail through SQL server with the code below but its breaking at the db.Execute strsend line with a 424 Object Required error. I've got some very similar code on other forms that works fine so I'm thinking I must be overlooking something obvious... Any thoughts? Have I tried to oversimplify or should I be using an alternative to recordsets that I removed.Private Sub CmdLSSend_Click()'Define variablesDim tostr As StringDim Replacetxt As StringDim Title As StringDim strsend As String'Check all fields completedIf IsNull(txtMessage) Then MsgBox "Please enter a message" Exit SubEnd IfIf IsNull(cmbRefer) Then MsgBox "Please select yourself from the list" Exit SubEnd If'Define recipient and fix "'" issuetostr = "address@work.ac.uk"Replacetxt = Replace(txtMessage, "'", "''")Title = "Learning Support Referral from " & Trim(Forms!frm_Student_Refer!cmbRefer) & " regarding " & Called'Send E-mail strsend = "exec sp_email @attach = '', @number = '" & tostr & "', @comment = '" & Replacetxt & "', @subj = '" & Title & "'" db.Execute strsend 'Open report for printingDim stDoc As StringstDoc = rpt_Student_LSReferDoCmd.OpenReport stDoc, acViewNormalMsgBox "Your form has printed to your default printer and an e-mail has been sent"'Close Form DoCmd.CloseEnd Sub |
|
AndrewMurphy
Master Smack Fu Yak Hacker
2916 Posts |
Posted - 2008-02-19 : 10:10:28
|
object out of scope?where/how is "db" defined? |
 |
|
scliffe
Starting Member
2 Posts |
Posted - 2008-02-20 : 09:09:07
|
*hangs head in shame!I oversimplified so much that I didn't define the db... oops.Just needed to add:'Define dbSet db = New Connectiondb.Provider = "SQLOLEDB"db.ConnectionString = "user id=******; data source=*******; initial catalog=****; password=********"db.OpenI knew it would be obvious for someone not staring at it all the time lol Thank you :-) |
 |
|
AndrewMurphy
Master Smack Fu Yak Hacker
2916 Posts |
Posted - 2008-02-20 : 09:54:48
|
bin there, tshirt copyrited!!! |
 |
|
|
|
|