473,395 Members | 1,474 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

getting error in line Forms!Form3!DeptID = rs.Fields("DeptID")

Expand|Select|Wrap|Line Numbers
  1. Public Sub EmailTemplates()
  2.     Dim db As DAO.Database
  3.     Dim rs As DAO.Recordset
  4.     Dim MailRecipents As String
  5.     Dim MailRecipents1 As String
  6.     Dim MailRecipents2 As String
  7.     Dim objOutlook
  8.     Dim objEmail
  9.     Dim BodyEmail As String
  10.     Dim Department As String
  11.     Dim SubjectLine As String
  12.     Dim Frm As New Access.Form
  13.   BodyEmail = " Kindly find the attachment for GL Numbers.Fill in the balance and please dont change any thing other than Balances "
  14.     DoCmd.SetWarnings False
  15.     DoCmd.OpenForm "Form3"
  16.     Set db = CurrentDb
  17.     Set rst = db.OpenRecordset("email_final")
  18.     Set rs = db.OpenRecordset("email_final", dbOpenDynaset)
  19.     Set Frm = Forms("Form3")
  20.     With rs
  21.  
  22.  
  23.         Do Until .EOF            
  24.                 Department = rs.Fields("DeptID")
  25.  
  26.  
  27.                 SubjectLine = " General Ledger template "
  28.                Forms!Form3!DeptID = rs.Fields("DeptID")
  29.                 MailRecipents = rs.Fields("address1")
  30.                 MailRecipents1 = rs.Fields("address2")
  31.                 MailRecipents2 = rs.Fields("address3")
  32.                 Debug.Print MailRecipents
  33.                 Debug.Print MailRecipents1
  34.                 Debug.Print MailRecipents2
  35.  
  36.  
  37.                 If Department <> rs.Fields("DeptID") Then
  38.                     DoCmd.SendObject acSendQuery, "testTemplate", acFormatXLS, MailRecipents, MailRecipents1, MailRecipents2, SubjectLine, BodyEmail, False
  39.                 Else
  40.                     DoCmd.SendObject acSendQuery, "testTemplate", acFormatXLS, MailRecipents, MailRecipents1, , SubjectLine, BodyEmail, False
  41.                 End If
  42.  
  43.            rs.MoveNext
  44.  
  45.  
  46.     Loop
  47. End With
  48. rst.Close
  49. Set rst = Nothing
  50.  
  51.     Set rs = Nothing
  52.     Set db = Nothing
  53.     DoCmd.SetWarnings True
  54.  
  55. End Sub
Have used the testTemplate query = SELECT DISTINCT (tblGLNumbersNew.AcctNo), tblGLNumbersNew.[Account Name], tblGLNumbersNew.DeptIDRef, tblGLNumbersNew.[Account Type], date() AS EOM, CCur(0) AS [0-30 Days Amount], CInt(0) AS [0-30 Days Items], CCur(0) AS [31-60 Days Amount], CInt(0) AS [31-60 Days Items], CCur(0) AS [61-90 Days Amount], CInt(0) AS [61-90 Days Items], CCur(0) AS [Over 90 Days Amount], CInt(0) AS [Over 90 Days Items], CCur(0) AS [Total Amount], CInt(0) AS [Total Items]
FROM emailaddress INNER JOIN tblGLNumbersNew ON emailaddress.DeptID=tblGLNumbersNew.DeptIDRef
WHERE (((tblGLNumbersNew.DeptIDRef)=Forms!Form3!DeptID))
ORDER BY tblGLNumbersNew.DeptIDRef;
Sep 6 '10 #1
1 1177
Stewart Ross
2,545 Expert Mod 2GB
Hi. It is not easy to read a bunch of code without an explanation about what it does and what you've already tried in debugging the error. I've added code tags around the VBA segment to make it easier to read your code, and to refer to individual lines within it.

Since your error is occurring at line 28 above, and not at line 24 which is the first reference to field DeptID, it suggests that either there is no control named DeptID on Form3, or that Form3 is non-updatable (or bound to a data source which is non-updatable).

-Stewart
Sep 6 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: IMS.Rushikesh | last post by:
Hi Friends, My work is stuck up because of this unresolvable and unbelievable Error. I'm trying to Serialize my Class object using XmlSerialization. And at below line, I m getting "error File...
8
by: Rod | last post by:
I have been working with ASP.NET 1.1 for quite a while now. For some reason, opening some ASP.NET applications we wrote is producing the following error message: "The Web server reported...
3
by: AMD Desktop | last post by:
Hi, I need to add a header to a datagrid. This is the code I am trying to use: Dim dgStaffingReport As New DataGrid Dim dgitem As New DataGridItem(0, 0, ListItemType.Header) Dim mycell...
10
by: Al | last post by:
Hi, I am seeking to obtain the line number of an error once deployed with out inserting line numbers in the method. The IDE inserts line numbers but this function does not appear to be a...
3
by: Rotsey | last post by:
Hi, I am trying to write some error handling code to log the error. But getting the line number of the error is not simple. Is it because the app is set to "Release" and does not have debug...
0
by: Rod | last post by:
I've recently upgraded to Crystal Reports 11 Release 2 on my development machine. Right now I'm trying to get one of our ASP.NET 1.1 applications working with it. Several pages already work with...
8
by: ipy2006 | last post by:
In my HTML I have, <input type="button" class="cartonsumkey" value="Sum Cartons" onclick="sumup(this);" /> In an external file that is called in Head area, I have, function sumup( o ) { ...
5
by: Archana | last post by:
Hi all, I am having application where i am downloading xml content using webrequest. my code is as below HttpWebRequest lWebRequest = (HttpWebRequest) WebRequest.Create(URL); HttpWebResponse...
21
vikas251074
by: vikas251074 | last post by:
I am getting error while entry in userid field. When user enter his user id, an event is fired immediately and user id is verified using AJAX method. But I am getting error 'Object doesn't support...
1
by: Omendra | last post by:
Hi, I am using SQL Server 2005 and i am using Stored Procedure something like :- I am getting error:- Msg 170, Level 15, State 1, Line 18: Incorrect syntax near 'MAX'. DECLARE @jid AS...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.