Page 2 of 2 FirstFirst 12
Results 16 to 26 of 26
  1. #16
    Rawb is offline Expert
    Windows XP Access 2000
    Join Date
    Dec 2009
    Location
    Somewhere
    Posts
    875
    ROFL

    grats!

  2. #17
    Steven.Allman is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Feb 2010
    Posts
    118
    OK man. You are a huge help. Got that all working, and it is looking at my current table. I can create the query, to pull the contacts for company A when I am looking at company A in the records, but I dont know how to make the code refer to that query when I hit the button.
    Right now its pulling ALL contacts.. Obviously I need it to just pull contacts for the specific unit I am looking at on with my form
    Do I need to open a whole new form?
    In other words, units are identified by a UIC, PYDAA is an example
    When i am looking at my form, and pull PYDAA, and want to email the contacts in that unit, how can the button perform both functions, Run the query and pull contacts from PYDAA, and then initiate the email...

  3. #18
    Rawb is offline Expert
    Windows XP Access 2000
    Join Date
    Dec 2009
    Location
    Somewhere
    Posts
    875
    There are two ways of doing that. The first way is to load the whole Table into your Recordset and then Filter it down to just what you want. The second way is to (either partially or completely) Filter the contents of your Recordset from the start and then, if necessary, Filter it further.

    I'm taking a shot in the dark here, but I'm guessing your Table has a lot of Records in it. Since that's the case, I'd recommend the second option. It loads the Recordset faster (and thus, runs the code faster) if it doesn't have to load all those extra Records.

    Let's assume the people listed in the database each have a unique identifier called (because I know nothing about the military) DogTagID that's a Text String. Let's also assume that you have a Text Box somewhere in your Form that's called DogTag which will display the selected individual's DogTagID value from your Table.

    Just change the Set rstContactList Recordset's "Set" line to something like the following:
    Code:
    Set rstContactsList = CurrentDb().OpenRecordset("SELECT * FROM TableName WHERE [DogTagID]='" & Me!DogTag & "'", dbOpenDynaset)
    If DogTagID is a number instead of text, just remove the single quotes from the Query. like so:
    Code:
    Set rstContactsList = CurrentDb().OpenRecordset("SELECT * FROM TableName WHERE [DogTagID]=" & Me!DogTag, dbOpenDynaset)

  4. #19
    Steven.Allman is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Feb 2010
    Posts
    118
    That worked great... The hardest part about learning access like this is figuring out when someone puts writes code for you, what is a variable for YOUR table, and what is a variable for access...
    hence, I knew DOGTAG was where i put my info in, but I changed the * to UIC and crap like that.. It was only one line so not much to figure, but DAMN, sometimes it gets crazy..
    I will be messaging you alot in the next few days probably..
    This is working just like I had hoped...
    I will let you know


    Thanks

  5. #20
    Rawb is offline Expert
    Windows XP Access 2000
    Join Date
    Dec 2009
    Location
    Somewhere
    Posts
    875
    I'll be here.

    And yeah, Access is a weird language to learn, especially if you've already got experience with a C-style language under your belt.

  6. #21
    Steven.Allman is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Feb 2010
    Posts
    118
    I have NO experience with any langage except English. I dabbled in HTML back when putting frames in your homepage were AWESOME!!!!!
    One last thing though, where do I put the ; without causing an error in the syntax. ; for multiple recepients....

  7. #22
    Steven.Allman is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Feb 2010
    Posts
    118
    RAWB, I updated my database to a 2007 database and I lost the email function. It gives me a Runtime '13' error, type mismatch. Code line is
    Set rstContactsList = CurrentDb().OpenRecordset("SELECT * FROM contacts WHERE [UIC]='" & Me!UIC & "'", dbOpenDynaset)

    However, I backed up first, so I open up the 2003 version of the database and it works fine. Checked the code, everything matches perfectly. Don't know what the deal is. Any ideas?

  8. #23
    Rawb is offline Expert
    Windows XP Access 2000
    Join Date
    Dec 2009
    Location
    Somewhere
    Posts
    875
    If I were to guess, I would say that it's because UIC is of a type Number instead of Text.

    Try changing that line to the following and see if it works (all I'm doing is removing the quotes from around Me!UIC).

    Code:
    Set rstContactsList = CurrentDb().OpenRecordset("SELECT * FROM contacts WHERE [UIC]=" & Me!UIC, dbOpenDynaset)
    P.S.
    I'm having to leave to run some work errands so I probably won't be able to reply again for the next couple of hours

  9. #24
    Steven.Allman is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Feb 2010
    Posts
    118
    DAO.recordset I found it on another thread somewhere. Apparently that is a common problem.

  10. #25
    Rawb is offline Expert
    Windows XP Access 2000
    Join Date
    Dec 2009
    Location
    Somewhere
    Posts
    875
    Ah yes. Sorry, I should have thought of that too.

    There are two major libraries for this kind of thing, ADODB and DAO. Personally I prefer DAO (no reason really, it's just what I use), but Access doesn't always include that library library. And when it does, it typically includes the other library too (so you need to specify which one you're using or Access gets confused).

    Glad you got it sorted out though.

  11. #26
    Steven.Allman is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Feb 2010
    Posts
    118
    I just started a new thread about adding multiple reports to the same email. Got any insight? This database is really getting crazy. It could change the way my office does business though.. I appreciate your help with all this

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Sending email
    By nashr1928 in forum Reports
    Replies: 8
    Last Post: 04-27-2010, 11:14 PM
  2. VB code for sending email through Option Group?
    By getdpt in forum Programming
    Replies: 0
    Last Post: 08-23-2009, 03:59 PM
  3. SENDING EMAIL MESSAGES DIRECTLY FROM ACCESS
    By Frenchos in forum Access
    Replies: 0
    Last Post: 07-20-2007, 12:51 AM
  4. Replies: 1
    Last Post: 03-09-2006, 01:50 PM
  5. Sending email via Outlook (and Exchange2003) from Access2003
    By Larry Elfenbein in forum Programming
    Replies: 0
    Last Post: 11-15-2005, 09:03 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums