Thanks Jon! If I were to transfer greyishly-legal materials, that would be very useful. ::looks shifty::
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!
You're welcome!
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
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.
Probably the error was from posting-
I will look at the queries- I usually understand those!
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.
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?
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.
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...
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.