Modules & VBA :: Looping Through Toggle Buttons To Email Reports
Apr 4, 2014
I have VBA to send multiple reports to a group of people depending on a toggle button selection. what I'm wanting to do is have it loop through the e mail process until all 5 toggle buttons have been selected and the reports have been E Mailed. Is this possible. Toggle buttons are named toggle1, toggle2 and so on.
I have built a end user form with multiple toggle buttons with "Yes/No" properties. I am wanting to link the buttons together, so if all have been selected/pressed it will read "pass" in a text box, but if even one is not selected it will read "fail". I was successful with the programming for one but not sure how to link them.
I want to automate the distribution of individuals Vacation Balance and Usage via email. The data is being pulled from 2 tables related by an Employee ID#. tbl-Employees provides the Header Info for each employee and tbl-VacLog provides the detailed Usage data.
I want the output to appear as follows in the body of the email:
Name Start Date Vac. Bal TotVacToEOY Personal Bal. John Doe 1/1/99 120 160 8
Usage Date Hours Reason Code 1/1/13 8 V 2/15/13 12 V 3/6/13 8 V
I've got a handle on creating the email and sending but where I'm having trouble is in making the link between the two tables with the Employee ID# and printing the corresponding detail data with Parent Record.
Code below...
Option Compare Database Sub SendMails() Dim DB As Database Dim RecordSetA As DAO.Recordset Dim RecordSetB As DAO.Recordset Dim TotalRecordsA As Integer
Hi - I have another problem. I hope you can help me out on this one.
Right now, I have 3 toggle buttons to control the visibility of 3 subforms. However, I only want a single subform to show at any given time. So, if I were to select toggle 1 it should give me subform 1, and afterwards if I select toggle 2 it should give me subform 2 WITHOUT showing me toggle 1.
Is there anyway to get the toggle buttons to work with each other?
I have a frame on a form with 2 toggle buttons in it - i want to be able to toggle the buttons to set criteria for a query which i can load as a report from clicking a button - is it possible to do with IFF? or is there an easier way - is it possible to have the report as a sub-report on the form and it to change when i toggle the buttons?
I have a form with about 40 Toggle buttons on it. I want the form to populate from a table. This table stores the status from rooms.
My table name is [Room] Fields [Room] and [Room_Status]
I want to call the button BtnBS1 (Room BS1) and if the status for that room is occupied the button when loaded will be RED, and if it is available it must be green.
I want the form to be an graphical overview of what rooms are occupied and what rooms are available. By clicking on a green room I want another form to open to allow me to fill it with data.
I have a tab control at the bottom of my main form, and some of the tab pages contain subforms. On one of the subforms I have created a filter to divide the content into "complete" and "incomplete." I have also added a toggle button option group to the subform to toggle the filter (one button for "complete" and one for "incomplete"). I'm using a macro to apply the filter, but it isn't working. The filter does work properly if I use the "Toggle Filter" button on the Ribbon, but I want to create something a little more user friendly.
If [tgl_Complete_Incomplete]=-1 Then ApplyFilter Filter Name Where Condition =(([tbl_Action_Items].[Completed])=True) Control Name [Forms]![Search_by_name]![sfctlActionItems].[Form]![tgl_Complete_Incomplete] Else RunMenuCommand Command RemoveFilterSort End If
I get the error message "The 'ApplyFilter' action requires a valid control name that corresponds to a subform or subreport."
If I remove the content of the Control Name field and open the subform independently (i.e. not as a subform), everything works fine.
Just tried out ControlTip Text on some command and toggle buttons. The text pops up on some but not on others and I cannot determine what the difference is (the properties are essentially the same except for name, caption etc). What buttons work and what do not seems random but if I copy/paste a button that works, the copy always seems to work.
I have an option group with two toggle buttons. Is it possible to set up the option group such that only one toggle button is visible at any given time (i.e. the unselected option) So the group has a default value. Clicking the visible button should switch the value, hide the button (option) associated with that value and show the alternate button (option) for the alternate value?
Basically only having one visible button at any given time which toggles between the two values (but I'd like to retain it as an option group, rather than as two independent buttons, as that gives me a handy value from which to determine control sources elsewhere)
I've tried setting the visibility of the buttons from the AfterUpdate event of the option group but it doesn't work.
I know I can do this with independent buttons but was hoping there was a quick(er) and easy way to do it with an option group instead?
With the code below , I send the report: “ESERT4H”, in email body. How I could add yet another report on the same body of the email ?
DoCmd.OutputTo acOutputReport, "ESERT4H", "HTML(*.html)", "D:Access empESERT4H.html", False, "", 0, acExportQualityScreen Dim Out As Outlook.Application Dim NS As Outlook.NameSpace Dim Folder As MAPIFolder Dim Mens As MailItem
I am trying to send a report to a list of employees. I have a query that generates the report into the layout I want and includes the e-mail address of who the recipient should be. The report looks something like this:
I need to send, for each row in the query, this report based on the results of that particular row. How would I go about making a e-mail template that would be used, or at least sending the report as a PDF attachment? I've seen the sendObject method.
Body (pre filled with "Dear ([Contact]if possible) Please find enclosed your documentation for your recent telephone order bla bla bla and our logo.jpg if possible)
then i would like to attach to the email the cover letter/invoice(report), book page(report) and the book (pdf) from the hard drive (r.eports changed to pdf)
if i can press a button on the form to send it that would be good.
if i could link it to a query to send a batch of them that would excellent.
The Database is Named: b4s.mdb The table is called: Main Table The input form is called: Client The letter/invoice report is called: b4sletinv The Book page report: b4sbook The pdf book is located at c:Documents and SettingsAdministrator4sfinal.pdf The query for the batch is called: coverlet&proforma
I am trying to make an automation in order generate reports based on query ( person name,person email address ) , export them to a folder in PDF and then send them one by one to each person email address.
What is happening:
- the reports are generated and exported fine - the email are sent to the right addresses but the first person receives the correct report , the second person receives the report from the first person plus its own report and so on.
Here is my code :
Private Sub MakeReportSendEmail_Click() Dim MyDB As DAO.Database Dim MyRS As DAO.Recordset Dim strSQL As String Dim strRptName As String
Have found some code that originated from this forum, and have modified it to suit my needs. There's one form with all the information, that has multiple buttons and subsequently multiple functions to generate emails, with each button/email to generate a different format and content. The first use of a button works fine, but trying to use the next button right after does nothing. If you exit the form and re-enter, you can then use the next email button, but that's a pain and the users won't like that. Can anyone help? I've pasted a sample of the code that is being used below, it's duplicated and changed slightly for the other buttons. I currently have the button linked to a macro that does other things like saving, and setting dates and then running the function.
Thanks, Don ----------------------------------------------------------------- Public Function AckEmailNew() On Error GoTo Err_cmdMailTicket_Click
Dim varTo As String '-- Address for SendObject Dim stText As String '-- E-mail text Dim stSubject As String '-- Subject line of e-mail Dim stTicketID As String '-- The ticket ID from form Dim strSQL As String '-- Create SQL update statement Dim errLoop As Error
varTo = Me.ClientEmail stTicketID = Me.STSITicket
stSubject = "Ticket/numro de rfrence: " & stTicketID
stText = <<My text goes here>>
'Write the e-mail content for sending to assignee DoCmd.SendObject , , acFormatTXT, varTo, , , stSubject, stText, -1
Hello to all the Users! I am new at Access and new to programming. I have created an Access form that has four labeled control buttons each one with an individuals name. I have the corresponding code:
Private Sub Email_PersonOne_Click() DoCmd.SendObject acSendNoObject, , , "personone@yahoo.com", , , "Work Request", "A new work request has been submitted." End Sub
When I have one button and one code the email function works. I want the users to be able to select one out of four people who they want to notify upon completion of the form. So I have four buttons and changed the email address and the names on the buttons but now none of the buttons work. The code is on the same page separated with just a line between each section.
Does this make sense? Any input would be greatly appreciated. Thanks in advance for your time and help. Sincerely, DebraF
I have learned the basic looping technique for going through a record set from the following link. I need to know if my logic is on the right track. URL...
My question is a followup to a thread that was opened on this forum: URL....I want to do the following:
1) Use record set looping technique to fix a variety of incorrect naming conventions to a standard format 2) Update the table (or create a new table) from the updated record set values. (Is my logic going to update the table selected in the code I used to dimension the record set or will I need to do something else to make the changes available for other tasks after record set is closed ? After the naming conventions are fixed this data will be available for excel automation that I am working on and posting questions on another thread in this forum. HAHA I'm going code BANANAS) 3) rs.fields![fleetlocation] is used so many times, how can I make this a variable (what do I dimension the variable as?) 4) Use an AND statment with an if statment (how to do this with correct syntax)
Code: sub loopandfix() on error goto errorhandler: strSQL = "tblUnionQueryResults" 'table was created from a union query but has inconsistant naming conventions for the fleet location name
I have the following example of code I have previously used which loops through columns where a column is called "Page1", "Page2", Etc.This is fine when the number of columns is fairly small. But in a new case I have 585 250 columns which may or may not contain some data which is the key.If data exists in column do something and after that or of not move to the next column and do the same thing until there are no more columns?
Code: Dim rst As DAO.Recordset ' recordset for category data ' open the recordset for categories Set rst = CurrentDb.QueryDefs!QryRMA.OpenRecordset ' loop through the rows in the recordset rst.MoveFirst Do Until rst.EOF
Im still struggling with working with recordsets.What i want to achieve is to loop through a continuous form recordset, Using the OrderDetailFK from the record set and the OrderDetailPK in the OrderDetail Table
Looking at the Status FK in the OrderDetail Table. IF the OrderDetail Status = 2 then i want to make the textbox enable property = False. I have made the bellow SQL string which is placing all the criteria i just need to link it into a recordset?
Code: mySQL = "SELECT [StatusFK] FROM [tblOrderDetail] WHERE [OrderDetailPK] = " & rst!OrderDetailFK & " AND [StatusFK] = 2 "";"""
I have a looping error on this code. It all works fine until the very last row, on the last row it brings over the Claim_Number and the FacID, but leaves the Paid_Amount blank.
If I have 10 or 10,000 rows, its always leaves the Paid_Amount on the last row blank.
Code: Function RunLWSPA() Dim cnn As ADODB.Connection Dim rstUplo As New ADODB.Recordset Dim rstDiag As New ADODB.Recordset Dim rstTemp As New ADODB.Recordset
I have managed to amend records based on the user selecting multiple items in a list box by using the following code.
Set db = CurrentDb() Set rs1 = db.OpenRecordset("Usage", dbOpenDynaset, dbAppendOnly) Set ctl = [Forms]![frmsearch]![lstSelector]
[Code].....
what I need to do now, is to loop(I think) through and amend all the records in a populate listbox, with no selections, similar to above, but without selection.
This query returns a running asset balance for 60 months. Each month is 1 column.
1) I need to create a query based on those results that can cycle through each column and determine if it is NEGATIVE. Then if it is negative, I need to perform some math on it to determine how to get it back up to being positive.
2) I need to loop through X columns based on the assets lead time. Each lead time varies and I have a master table that contains it. So if the assets lead time is 3 months, I need it to move over 3 columns and return that value. If it is 6 months then I need it to return the value in the 6th column.
I have 3 tables; tblProjects, tblTesting, and tblEmployees.
The issue I'm having is that I've created a form which collects testing information from testers that test a particular project. Each project can have multiple testers. tblProject and tblTesters have a one to many relationship and the form (frmTesting) consists of a main form for project info and a subfrom for testing info.
For each project tested there are 4 possible outcomes. 1st not all testers have tested to project and that case project status is "InTesting", 2nd all testers pass testing in that case project staus is "Waiting Final Approval", 3rd all testers fail testing in that case project status is "Maintenance" and last some testers pass and some fail in that case project status is "IPR".
Here is my code for a button I've placed on the sub form.
Private Sub BtnTest_Click() Dim db As DAO.Database Dim rsSQL As DAO.Recordset Dim intMax As Integer Dim strSQL As String Dim csSQL As String Set db = CurrentDb()
[Code] ....
My select statement for my recordset isn't working and I've tested it by putting a specific project number in the statement and I still only pulling one recordset.
Im v new to VBA and been having trouble getting the following code to loop through the records in my subform:
Private Sub cmdComplete_Call_Click() Dim rs As dao.Recordset Set rs = Me.fsub_Call_Off_Quantities.Form.RecordsetClone rs.MoveFirst
[code]....
It only seems to update the first records txtQuantity_Called_Off value. I have tried all the 'looping' code variations i can find and they all seem to only update the first .
When I run the following sql (in a query) I enter information once for [enter cty id]. and it all works fine.
What I would like to do now, is write the vba code so that the sql runs multiple times looping through a list of items.
For instance instead of the popup window asking "enter cty id", I'd like to automatically have the code loop through a list. For example a list of 1 through 10.
Then, in the loop vba code:
after item 1 is run, do an export of the results. after item 2, do an export. etc.
Code:
select a.south_index_id, c.cnty_cd, a.southwest_name_source_cd, sp.south_ssn, sp.estimated_birth_dt, [a.LAST_NAME] & ', ' & [a.FIRST_NAME) PERSONNAME], a.BIRTH_DT, a.GENDER_CD, sp.ms_pmi, cnty_person_id FROM SW_alias_name AS a, SW_south_person AS sp, SW_county_pid AS c WHERE EXISTS (select * from SW_alias_name a2 where ucase(a2.last_name) = ucase(a.last_name)
I follow a ritual of moving last to first before looping through a recordset. I started following this because in the way back (I think on office 2003). I used to get an error if don't do it. Is the problem still exists? Is this ritual scientific still?
Code: Sub mac() Dim myRset As Recordset2 Dim AttachmentField As Field2 Set myRset = CurrentDb.OpenRecordset("Table1") With myRset .MoveLast