I Figured Out The Problem, Now Please Help Me Solve It - Search/Email Results
Nov 30, 2004
Ok here is what was going on. I have an option group, I would select an option,
type in my search criteria into a text box, and click an event button. The program
would then search my database for that criteria and grab the emails of the individuals
meeting that criteria. A message box would then pop up, listed all the emails it had grabbed
I would click ok (my sendobject command is set to edit the email) and at this point instead of
opening the email to edit the program would crash.
After scratching my head for several days I moved on and have come back to this problem again
two weeks later, and within 15min I realized what was wrong. I guess it is good to walk away
and come back fresh sometimes.
What is happening is that the program does not account for entries in my database that do NOT
have an email.
Example, let us say we want to search a state...lets use the state of GA for example. If I have 5 entries
from GA with email addresses and one entry from GA without an email address, it will crash the program.
My only guess is that the way the program is setup is that it is grabing whatever data is in the email location.
It that location is blank, its grabing blank and crashing the program.
I need a way to discard the entries it searches that don't have email addresses or something...
Please help, this is the last item for this project.
Here is the current code:
Code:'Code by M. Walts'Important information! this code requires a reference to the Microsoft DAO object libraryOption Compare DatabaseOption ExplicitPrivate Sub cmdEmail_Click()'will hold the dynamic SQL queryDim strSQL As String'will hold the WHERE clause portion of our SQL queryDim strWHERE As String'will hold all the recipients of this messageDim strRecipients As String'the recordset we will use to get the emails of the records that match our criteriaDim rst As DAO.Recordset'if there is input in the search criteria, then we will run the query and send the e-mailIf txtSearch <> "" Then'if you have more buttons, just add mosr cases (the value of the radio button'= the Case number, so Value of the State radio button is 1, etc.)Select Case opgSearch.ValueCase 1strWHERE = "WHERE State = '" & txtSearch & "'"Case 2strWHERE = "WHERE PrayerSupport = '" & txtSearch & "'"Case 3strWHERE = "WHERE Denom = '" & txtSearch & "'"Case 4strWHERE = "WHERE PACTTrainer = '" & txtSearch & "'"Case 5strWHERE = "WHERE PACTPartner = '" & txtSearch & "'"Case 6strWHERE = "WHERE City = '" & txtSearch & "'"Case 7strWHERE = "WHERE Donor = '" & txtSearch & "'"Case 8strWHERE = "WHERE MailingList = '" & txtSearch & "'"Case 9strWHERE = "WHERE Conference = '" & txtSearch & "'" Case 10strWHERE = "WHERE YouthPastor = '" & txtSearch & "'"Case 11strWHERE = "WHERE PreviousCustomer = '" & txtSearch & "'"End SelectstrSQL = "SELECT EMail FROM tblUser " & strWHERE'run the query and get the results into the recordsetSet rst = CurrentDb.OpenRecordset(strSQL)'Loop through the recordset and add all the EMailsDo While Not rst.EOFstrRecipients = strRecipients & ";" & rst!EMailrst.MoveNextLoop'remove the first ; from the strRecipientsstrRecipients = Right(strRecipients, Len(strRecipients) - 1)MsgBox strRecipientsDoCmd.SendObject , , , , , strRecipients, "Email Subject", "Email Body", Truerst.CloseSet rst = NothingEnd IfEnd Sub'stops a ' entered in the field from breaking the queryPrivate Function SQLSafe(safeMe As String) As StringSQLSafe = Replace(safeMe, "'", "''")End Function
View Replies
ADVERTISEMENT
Oct 14, 2004
***Updated*** Search/Email Results has been solved....Working out some bugs and trying to add a Print Address Labels option to the search. The post at Date Nov. 5, 11:4x is the new post with updated info. Thanks! ***Updated***
I have read a ton in the last hour or so on this subject and gained a little insite, but since I have no Access programing experience I am still pretty lost. However, I have programing experience in other areas, so if it requires some macros, I shouldn't have too much trouble. /crossfingers
I have put together a database for the business I work for that contains around 3,000 contacts.
I am trying to figure out a way to do a search that will search out specific contacts and email them a newsletter. Their email address is included in their contact information. So I assume I need a way to search for a specific criteria, grab their email address, and then email them with either an attached document, a prior written email, or have included the newsletter in the body of the code to add into the created email.
Any thoughts?
Thanks so much for your time,
Nick
View 14 Replies
View Related
Nov 15, 2004
I'm getting a Run-time error 2295: Unknown Message Recepients.
I've got a DB of about 2000 clients. In testing I did a test DB with 50 random
clients. Using any search criteria, it would grab those clients and open a new email
with their email addresses no problem.
However when I do this same thing with my complete DB of 2000 clients, I get this run
time error.
I'm pretty confused here, and anxious. It looks like the program is working, I just need it
to run with all my clients. This is the last thing I must conquer to be finished with this project.
View 3 Replies
View Related
Apr 29, 2014
I have built a custom search form in a MS Access 2010 database so that users can find specific records to edit. After entering the search criteria and hitting a Search button, another form opens up that shows the search results. This second form includes a command button for generating a report of the search results.
Right now, the custom search form and the search results form are both working properly, but the search results report is showing every record in the database instead of just the search results. This is true whether I access the report via the command button in the form or the navigation pane. I'm not sure if I need to correct my VBA code or the report's properties.
View 4 Replies
View Related
Jun 24, 2015
I have a form that has a subform on it. The main form shows a category of furniture and has custom navigation buttons and a search text box for asset numbers and command button that runs the search. The subform shows the asset numbers associated with that furniture category, sometimes there is only one asset number, in other cases there could be 60. There is a scroll bar to scroll through the asset numbers when there are too many to see in the initial window.
The buttons all work as they should except when I search for an asset number that is part of a category that has too many asset numbers to show in the main window. When this happens the "previous" and "next" navigation buttons do not take you to the previous or next record. All of the other buttons on the form work though - you can go to the first, or the last record, and you can search for a new asset.This is the code for the search:
Code:
Private Sub cmdAssetSearch_Click()
Dim rs As Object
If IsNull(Me.TextAsset) Or Me.TextAsset = "" Then
MsgBox "Please type in an asset number to search for.", vbOKOnly
Me.TextAsset.SetFocus
[code]....
I've also attached a picture of what I mean when I say there are more asset numbers than what the window shows.
View 6 Replies
View Related
Aug 5, 2014
I have a search form that uses a query to show results of a search, but everytime I press search everything comes up even though I have entered search parameters, even though my search requeries every time and the search used to work before I added new records today. Also when I press the query alone on the navigation pane it asks me for the parameters and then it actually works but it won't when I use my form.
View 2 Replies
View Related
Dec 6, 2005
I hope I can explain this clearly. I'd be really grateful if anyone could help.
I need to set up some sort of contacts database at work.
I need (I think, after having a little think about it) one table, filled with people, (their names, contact details ect) and basically various queries to pull up people in certain groups. Say for instance, people who attend meeting a, b, c, (in a simplised, condensed version of the truth)
I did think about doing this with various tables actually. A contacts table, a meetings table, blah blah, but anyway. (Any advice on this incidentally would be great).
My main problem though. We often have to email all the people who attend say meeting a. We have contacts on our email systems, but they're different from person to person, and as the company is updating email systems, we can't even send contacts lists to everyone, as they're not compatible.
What I'd love is to be able to call up a list of people attending meeting a from my database and email each of those people (their contact details would include email address of course)
Does that make sense?
Is there any way of doing this?
I'd be really happy if anyone knew...
View 9 Replies
View Related
Nov 21, 2007
I am using code to email query results as html to named recipient. I now want to send the results of a query that returns results with mulitple email addresses so that appropriate returned record is emailed to the relevant email address.
record1 - email1
record2 - email2 etc.
Any code help appreciated.
View 1 Replies
View Related
Aug 31, 2007
I am having the same issue.
Can't seem to find a solution to my problem here or in a few reference books I have on my shelf here at work.
I inherited several access databases from my predecessor a while back and although I’ve fixed most of the pre-existing problems and re-programmed most of the queries and reports at this point I’m stumped on one issue. One of the access files forces me to save every query, form or report I create no matter what. If I create a query because I want to do a quick one time query I can’t just close it and say no to saving when I’m done, I have to save it and then go back and delete it if I don’t need it anymore. I can’t track down any setting or code anywhere in this one access file that would cause this behavior to be different than all of the other dozen or so databases I inherited. This becomes a big issue in the case of if I accidentally do a major change I didn’t mean to that the undo command doesn’t correct, if I go to close it saves the query if it’s been saved before and makes my error permanent and I have to go dig out the nightly backup to undo the mistake.
Any thoughts on where to find or change this setting would be great as I’ve run out of ideas on my own.
View 1 Replies
View Related
May 24, 2014
I have created some code to get the records of a query and it puts them in the body of the email but it doesn't format it well for example the email looks like
James | halliwell | 31
Leanne | smith |27
Alexis | smith |8
I would like it to be in a table is this possible,
Code:
Public Function SendEmail()
Dim MyDB As DAO.Database
Dim rst As DAO.Recordset
Set MyDB = CurrentDb
[Code] .....
View 3 Replies
View Related
Apr 1, 2014
I have got a form (name: SearchForm) that displays results of a query (name: AircraftSearch). It is a continuous form displaying multiple results of a search done by the query. I need to be able to send an e-mail to multiple recipients chosen from results displayed on the form.
One of the form's field (a text box called: EmailToOperator) is containing e-mail address to an aircraft operator selected by the underlying query. I need to be able to place a check box button (or something similar) that is going to select the e-mail address. The tricky part is to have multiple check boxes allocated for each record displayed on the form and have them working independently.
The second task is sending a one message (via Microsoft Outlook 2010) to chosen multiple recipients (with no attachments) having the recipients' addresses not visible to each other.
View 7 Replies
View Related
Jun 27, 2013
I am trying to loop through a query results to extract email addresses from a query result.
I have the following code
NameCriteria = Forms![MainMenu]![tbl_Course_Details]![Course_Name].Value
DateCriteria = Forms![MainMenu]![tbl_Course_Details]![Course Date].Value
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim sqlStr As String
[Code] .....
If i run this in access as a query then it returns results but when i run in there then it says no current Record and i cant work out why?
Someone on another post said that sql uses US date format so i tried converting to us date and still no results?
View 6 Replies
View Related
Jun 28, 2006
Hi there,
I am setting up a database at the moment. I do not have a lot of experience with Access but up to know everything was alright :).
I don't know if it is at all possible...but I would like to be able to find out who has a yes in a "yes or no" field and than that it shows me the email addresses of the people that have a yes there....does that make sense...I hope so.
Ok if that is possible, the second thing I want to be able to do is to email those persons that have a yes.
I have understood by now I will need codes and everything. Problem is I don't know anything about creating codes...so would be great if someone can explain that to me. And is it right I put those codes into a new module?
I hope this all makes sense and that someone will be able/willing to help me.
Thanks in advance!
View 2 Replies
View Related
May 27, 2005
please can someone help me with a vb code to view search results in a subform such that
double clicking search result on subform displays another form with details of the result.
Heeeeeeelp.
Thanks
View 2 Replies
View Related
Oct 10, 2006
Following program i have written in access. what it does is from the query i have created picks up the sizes of doors. calculates hit1 by qty then it needs to put the value into another table alongside the correct sizes. the problem im facing is how do i update the value into another table. heres the listing.
Option Compare Database
Option Explicit
Dim Db As Database
Dim Rs1 As Recordset
Dim Rs2 As Recordset
Dim lf, rh, drw1, drw2, drw3, drw4 As String
Dim q1, q2, q3, q4, q5, q6, qty As Integer
Dim hit1, hit2, hit3, hit4, hit5, hit6 As Integer
Private Sub Command70_Click()
Dim rs1fieldcount As Integer
Dim counter As Integer
''Assign a mdb
''+++++++++++++++
Set Db = CurrentDb
counter = 0
Set Rs1 = Db.OpenRecordset("custdoorsize")
Set Rs2 = Db.OpenRecordset("cusdoorsbase", dbOpenDynaset)
rs1fieldcount = Rs1.Fields.Count
If Rs2.RecordCount = 0 Then
MsgBox "No record found in query"
Else
this is where the value will come from
Do Until Rs2.EOF
If Rs2.Fields!left_door_size <> Empty Then
lf = Rs2.Fields!left_door_size
hit1 = 1
q1 = hit1 * Rs2.Fields!qty
End If
If Rs2.Fields!Right_door_size <> Empty Then
rh = Rs2.Fields!Right_door_size
hit2 = 1
q2 = hit2 * Rs2.Fields!qty
End If
If Rs2.Fields!draw1_size <> Empty Then
drw1 = Rs2.Fields!draw1_size
hit1 = 1
q3 = hit3 * Rs2.Fields!qty
End If
If Rs2.Fields!draw2_size <> Empty Then
drw2 = Rs2.Fields!draw2_size
hit4 = 1
q4 = hit4 * Rs2.Fields!qty
End If
If Rs2.Fields!draw3_size <> Empty Then
drw3 = Rs2.Fields!draw3_size
hit5 = 1
q5 = hit5 * Rs2.Fields!qty
End If
If Rs2.Fields!draw4_size <> Empty Then
drw4 = Rs2.Fields!draw4_size
hit6 = 1
q6 = hit6 * Rs2.Fields!qty
End If
Do While counter <> rs1fieldcount
This is where it finds the correct sizes where it will display the qty value
If Rs1.Fields(counter).Name = lf Then
Rs1.Edit
Rs1.Fields(counter).Value = q1
End If
If Rs1.Fields(counter).Name = rh Then
Rs1.Fields(counter).Value = q2
End If
If Rs1.Fields(counter).Name = drw1 Then
Rs1.Fields(counter).Value = q3
End If
If Rs1.Fields(counter).Name = drw2 Then
Rs1.Fields(counter).Value = q4
End If
If Rs1.Fields(counter).Name = drw3 Then
Rs1.Fields(counter).Value = q5
End If
If Rs1.Fields(counter).Name = drw4 Then
Rs1.Fields(counter).Value = q6
End If
counter = counter + 1
Loop
If Rs2.EOF Then
Set Rs1 = Nothing
Set Rs2 = Nothing
Set Db = Nothing
MsgBox "Finished ....."
Exit Sub
Else
Rs2.MoveNext
End If
Loop
End If
End Sub
please help
View 1 Replies
View Related
May 8, 2006
Dear My Friends
I want to solve the follwing matter.
** Enter-Invoive Number
** Enter-Amount
If the amount 1000> - Show stamp duty as $1
If the amount 1001-2000 -Show stamp duty as $.2
If the amount 2001-3000 - Show stamp duty as $3
If the amount 3001-4000 -Show stamp duty as $4
Like wise upto 50,000
If the amount 50,000 < Show stamp duty as $50
I want to above results in access report with name of invoce number, amount and stamp duty .Please help as soon as possible
View 1 Replies
View Related
Jun 28, 2005
I created a search form (using code from here) that searches serveral fields and displays the results in a listbox. I also created a clear button to clear the fields, including the listbox. I can search all day and it works fine, and the CLEAR button clears out the fields fine but once I have clicked the CLEAR button, I cannot search anymore. I don't get any results anymore (until I close and reopen). It must be something simple that I am overlooking so any hints would be appreciated.
Here is my code (sorry it's long!):
Private Sub cmdClearForm_Click()
On Error GoTo Err_cmdClearForm_Click
Dim I As Integer
' Cycle through the form's controls, testing for text,
' and clear each field.
For I = 0 To Me.Count - 1
If TypeOf Me(I) Is TextBox Then
Me(I) = ""
ElseIf TypeOf Me(I) Is ListBox Then
Me(I).RowSource = " "
End If
Next
Me.txtMacAddr1.SetFocus
Exit_cmdClearForm_Click:
Exit Sub
Err_cmdClearForm_Click:
MsgBox Err.Description
Resume Exit_cmdClearForm_Click
End Sub
Private Sub cmdSearch_Click()
On Error GoTo Err_cmdSearch_Click
Dim strSQL As String, strOrder As String, strWhere As String, strOrderChoice As String
Dim db As DAO.Database
'Dim qryDef As QueryDef
Set db = CurrentDb()
strSQL = "SELECT tblAsset.MacAddr1, tblAsset.SerialNum, tblIPAddresses.IPAddress,tblIPAddresses.HostName, tblLocation.JackNumber, tblLocation.CircuitID, tblLocation.Department,tblLocation.SpecificLoc, tblLocation.User, tblLocation.Building, tblLocation.RoomNumber " & _
"FROM tblAsset, tblIPAddresses, tblLocation " & _
"WHERE tblAsset.AssetNum=tblIPAddresses.AssetNum and tblAsset.AssetNum=tblLocation.AssetNum"
strWhere = " and "
strOrder = "order by"
strOrderChoice = "tblLocation.Department"
If Not IsNull(Me.txtMacAddr1) Then
strWhere = strWhere & "(tblAsset.MacAddr1) like '*" & Me.txtMacAddr1 & "*' and "
strOrderChoice = "tblAsset.MacAddr1"
End If
If Not IsNull(Me.txtMacAddr1) Then
strWhere = strWhere & "(tblAsset.MacAddr2) like '*" & Me.txtMacAddr1 & "*' and "
strOrderChoice = "tblAssest.MacAddr2"
End If
If Not IsNull(Me.txtSerialNum) Then
strWhere = strWhere & "(tblAsset.SerialNum) like '*" & Me.txtSerialNum & "*' and "
strOrderChoice = "tblAsset.SerialNum"
End If
If Not IsNull(Me.txtIPAddress) Then
strWhere = strWhere & "(tblIPAddresses.IPAddress) like '*" & Me.txtIPAddress & "*' and "
strOrderChoice = "tblIPAddresses.IPAddress"
End If
If Not IsNull(Me.txtHostName) Then
strWhere = strWhere & "(tblIPAddresses.HostName) like '*" & Me.txtHostName & "*' and "
strOrderChoice = "tblIPAddresses.HostName"
End If
If Not IsNull(Me.txtJackNumber) Then
strWhere = strWhere & "(tblLocation.JackNumber) like '*" & Me.txtJackNumber & "*' and "
strOrderChoice = "tblLocation.JackNumber"
End If
If Not IsNull(Me.txtCircuitID) Then
strWhere = strWhere & "(tblLocation.CircuitID) like '*" & Me.txtCircuitID & "*' and "
strOrderChoice = "tblLocaton.CircuitID"
End If
If Not IsNull(Me.txtBuilding) Then
strWhere = strWhere & "(tblLocation.Building) like '*" & Me.txtBuilding & "*' and "
strOrderChoice = "tblLocation.Building"
End If
strWhere = Mid(strWhere, 1, Len(strWhere) - 5)
Me.lstResults.RowSource = strSQL & " " & strWhere & " " & strOrder & " " & strOrderChoice
db.Close
Exit_cmdSearch_Click:
Exit Sub
Err_cmdSearch_Click:
MsgBox Err.Description
Resume Exit_cmdSearch_Click
End Sub
View 4 Replies
View Related
Jan 2, 2006
Good Day All,
I have a wild card search query (Like "*" & [Forms]![search]![Text0] & "*") that works very well. I want to be able to have the phrase that user types in highlighted when it returns the search results on a form. I found the following thread that asks the same question using Conditional formating, but the suggested answer doesn't work. Any ideas?
http://www.access-programmers.co.uk/forums/showthread.php?t=73845&highlight=highlight+search
View 3 Replies
View Related
May 26, 2006
Whats the best way to filter search results?
I'll do my best to explain my problem:
I made a form that lets users search for records in a database and displays them in another form. In that form I've made 3 buttons to let users narrow down the results to show only certain items within the search results.
Now, 2 of the buttons show specific items and the third one toggles the form to display all the records. So lets say I'm filtering records by whether or not they contain the words "car" and "truck." If a record has "car" but not truck and I click the button to sort by "truck" then the search result goes blank, which is ok. But if I click "car" or "show all" to display everything again then the search result stays blank.
This doesn't happen with records that contain both "car" and "truck."
For every button I have something like this: DoCmd.OpenForm "AdminSearchResults", , "SOW", "VendName = '" & VendName & "'", , , "'VendName'"
I know my explanation may suck, but if anyone can help me, that would be great, lol
View 3 Replies
View Related
Feb 26, 2014
I am trying to query my records by the current records selected date then send the results in the body of an email on click. I believe I am close but I think there is a problem with the date format because I am getting 3421 Data type conversion error. Here is what I have:
Code:
Private Sub eMail_Click()
On Error GoTo EH
Dim dbExceptions As Database
Dim rstExceptions As Recordset
Dim dbDate As Database
Dim rstDate As Recordset
[code]...
View 3 Replies
View Related
Aug 23, 2007
I am fairly new to access and am curious if this is possible. I have a x number of procedures, I will use 4 as an example, with those 4 procedures I have a reference table that has certain devices for those 4 procedures that need to be compared against the device charges. ie
Procedure
1A
2B
3C
4D
Procedure Device Reference
1A has AAA,BBB,CCC,DDD
2B has AAA,EEE,FFF,GGG
3C has AAA,HHH,III,JJJ
4D has FFF,KKK,LLL,MMM
Device Charges has
AAA,III.LLL.ZZZ
Is there maybe a case statement that I can use to have access try to solve for the best combination of the devices with the procedure to give me the most matches possible and not match say AAA with 3C and LLL with 4D giving 2 out of 4 matches, instead of the result AAA with 1A,III with 3C, and LLL with 4D, and flagging ZZZ as not a match or it matches 3 out of 4
Im not sure if this is the best place for this but any help is greatly appreciated and if more information is needed please let me know thank you for your time in advance
View 3 Replies
View Related
Aug 31, 2006
I have looked all over for an answer, and I think there may have been a few examples on this forum that may have helped, but I only have Access 97, so can't open the example databases to fully understand!
Bascially, in the database I am trying to set up, I have Museum items, for instance a photo, and the database users would like to have a list of the names associated with that photo. (obviously for some items there will be no people associated with it, and varying numbers of people for other items!).
I need some way of having the 'associated people' data displayed on the item information form (or somewhere handy). And I need it to have the flexibility to account for differing numbers of associated people. Would using a subform solve this? And if I use a subform, where will that data then be stored? In its own table??
View 2 Replies
View Related
Nov 14, 2006
Hello,
My problem is this:
I want to retrieve some data from the database, the data is as follows:
pourcentage de processus évalués dans l’année
my problem is that when I am writing a querry for this...it gives me an error because of the << ' >> mark in the word << l'année >>
my querry is this...
strSQL = "insert into temp_indicateur (id,description) values(" & rs!id & ",'" & rs!description & "')
I am getting these values from another recordset.
Can anyone please help??
View 2 Replies
View Related
Mar 28, 2006
Using Access 2000 is it possible to specify a starting location ie (c:) and using VBA search every sub folder from this point for files ending .mdb or .xls?
I want to be able to build a table with an record showing the file name and directory for each file found.
Any help most appreciated.
Regards,
Dalien51
View 2 Replies
View Related
May 15, 2007
Item: Access app front end for an SQL database (production tracking/job logging utility)
Problem: The app has a main search page that allows job entries to be located and opened by varies criteria (job#, job name, etc). I can currently run multiple searches on different criteria successfully but if I open a job window(which has been returned as result of my search) and then close that job window to do a new search my search function will no longer return any results(other then “Calculating….”) unless I close out the access app and reload.
Thanks in advance for any ideas that can point me in the right direction to hunt down my bug.
View 1 Replies
View Related
Sep 22, 2006
Hey all,
I did a search and i found a thread that seemed like it would answer my question but for some reason the attachment isnt working. :(
Okay heres the question..
I have a form and it contains 3 fields and 3 command buttons.
When i hit the command button it uses a query to display the results.
What i want to do is instead of having the results display in a new window, i would like it to display on the same form .. maybe on the bottom of it.
Should i use a subform or listbox/combobox..
Can anyone help me figure this out?
Thanks in advance
View 2 Replies
View Related