Jayne, your mouth is talking. You might wanna look to that.

Mal ,'Serenity'


Buffistechnology 3: "Press Some Buttons, See What Happens."

Got a question about technology? Ask it here. Discussion of hardware, software, TiVos, multi-region DVDs, Windows, Macs, LINUX, hand-helds, iPods, anything tech related. Better than any helpdesk!


Theodosia - May 10, 2012 3:57:56 am PDT #20030 of 25501
'we all walk this earth feeling we are frauds. The trick is to be grateful and hope the caper doesn't end any time soon"

Thanks Jon! If I were to transfer greyishly-legal materials, that would be very useful. ::looks shifty::


Jon B. - May 10, 2012 4:18:42 am PDT #20031 of 25501
A turkey in every toilet -- only in America!

You're welcome!


Sophia Brooks - May 10, 2012 4:57:43 am PDT #20032 of 25501
Cats to become a rabbit should gather immediately now here

Are there people here who are familiar with Access/visual basic. There is a weird glitch in a database that I have which is set up to send confirmation emails when a student is registered for a class. If a student has registered for more than one class, it sends ALL the emails, even if that class was over years ago. This is set up as a button, with some VB code that makes a table with the student selected and then opens up a mail merge document. I can check in the merge document before sending and choose to only send one email, but that required me to remember that the student has registered before or be observant. And it is really hard to explain to my student trainees that do this.

The code for the button makes no sense to me (probably because I do not know VB)

Private Sub cmdOpenReg_Click()
On Error GoTo Err_OpenReg_Click
Dim db As DAO.Database
Dim qry As QueryDef
Set db = CurrentDb
If Not Me.cboClassName = "" And Not Me.cboStudentName = "" Then
MsgBox "You may only choose Class or Student but not both.", vbCritical
Me.cboClassName = ""
Me.cboStudentName = ""
Exit Sub
ElseIf Me.cboClassName "" Then
Set qry = db.QueryDefs("qryStudentPayEmailClass")
qry.Parameters("Input Class ID") = [Forms]![preLetterType]![cboClassName]
qry.Execute
ElseIf Me.cboStudentName "" Then Set qry = db.QueryDefs("qryStudentPayEmail")
qry.Parameters("Input Student ID") = [Forms]![preLetterType]![cboStudentName]
qry.Execute
ElseIf Me.cboClassName = "" And Me.cboStudentName = "" Then
MsgBox ("You must select a Class or Student before opening Registration Confirmation."), vbCritical
Me.cboClassName.SetFocus
Exit Sub
End If

Exit_cmd
OpenReg_Click:
Exit Sub

Err_OpenReg_Click:
MsgBox Err.Description
Resume Exit_cmdOpenReg_Click

End Sub


tommyrot - May 10, 2012 5:14:40 am PDT #20033 of 25501
Sir, it's not an offence to let your cat eat your bacon. Okay? And we don't arrest cats, I'm very sorry.

This is not valid:

ElseIf Me.cboClassName "" Then

It probably should be:

ElseIf Me.cboClassName = "" Then

But I'm guessing that's just a result of posting the code here? Anyway, assuming the code is OK on your end (because it's not erroring for you, right?), it looks like the actual problem is in one of the two queries this code can run--qryStudentPayEmailClass or qryStudentPayEmail.


Sophia Brooks - May 10, 2012 5:52:02 am PDT #20034 of 25501
Cats to become a rabbit should gather immediately now here

Probably the error was from posting-

I will look at the queries- I usually understand those!


Sophia Brooks - May 10, 2012 6:03:04 am PDT #20035 of 25501
Cats to become a rabbit should gather immediately now here

Ok- I just deleted my name! I thought I was emailing!

So, the way this was set up, there is a form with 2 drop down menus, one for students and one for classes.

There are 2 queries, one for students, which returns the student information from the all the classes from the one student chosen student drop down box and one for classes, which returns all student information for the class chosen in the drop down box.

All that is in the query currently is either [Input Student ID] or [Input class ID].

I think the ideal think would be to return the class most recently entered, but a) I don't know how and b) I don't know if that field exists, although I can add it.


tommyrot - May 10, 2012 6:58:56 am PDT #20036 of 25501
Sir, it's not an offence to let your cat eat your bacon. Okay? And we don't arrest cats, I'm very sorry.

OK, I think this is what you need:

Say you have a table called tbltest, with a unique ID of ID, a field 'stuff' and a dateadded field. You could try this:

SELECT tbltest.ID, tbltest.stuff, tbltest.dateadded
FROM tbltest

where tbltest.dateadded = (select max(dateadded) from tbltest)

However, if you have more than one record with the same maximum date, it will return all the records with that maximum date.

Is this what you need?


Sophia Brooks - May 10, 2012 7:13:50 am PDT #20037 of 25501
Cats to become a rabbit should gather immediately now here

I think so! Someday I will learn this stuff. We have a database designer, but I have been asking for this modification for over 3 years, and we are a really low priority.


EpicTangent - May 10, 2012 2:41:36 pm PDT #20038 of 25501
Why isn't everyone pelting me with JOY, dammit? - Zenkitty

Heh - I am Zen. I saw the start of a post and went, "Hey, I know Access!" but inside of two lines...blah blah Ginger...


Sophia Brooks - May 10, 2012 2:46:25 pm PDT #20039 of 25501
Cats to become a rabbit should gather immediately now here

The blah blah Ginger is sort of why I asked the question!

I do love that the "blah blah Ginger" is such a useful quote.