ROFL
grats!
ROFL
grats!
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...
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:
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)Code:Set rstContactsList = CurrentDb().OpenRecordset("SELECT * FROM TableName WHERE [DogTagID]=" & Me!DogTag, dbOpenDynaset)
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
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.
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....
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?
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).
P.S.Code:Set rstContactsList = CurrentDb().OpenRecordset("SELECT * FROM contacts WHERE [UIC]=" & Me!UIC, dbOpenDynaset)
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
DAO.recordset I found it on another thread somewhere. Apparently that is a common problem.
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.
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