Hi everyone,
I am trying to do something similar to thread702-940780, but keep getting an error.
I have a form that has an option group with 6 options. What I want the form to do on open is show all records. If one of the 6 options is selected, then filter the records for that specific Representative. I suspect I need another option 7 for ALL so that a user can have all records displayed. Not sure at this point. I also would need a way to pop up a message if NO records were found on any specific option (1 through 6).
Here is the code I have in a Module.
Here is the SQL I have as the form datasource.
When I open the database, I keep getting Error 2427, You entered an expression that has no value.
Can anyone tell me where I am going wrong with this code?
Thanks,
Dom
I am trying to do something similar to thread702-940780, but keep getting an error.
I have a form that has an option group with 6 options. What I want the form to do on open is show all records. If one of the 6 options is selected, then filter the records for that specific Representative. I suspect I need another option 7 for ALL so that a user can have all records displayed. Not sure at this point. I also would need a way to pop up a message if NO records were found on any specific option (1 through 6).
Here is the code I have in a Module.
Code:
Option Compare Database
Public Function OptMask()
Dim frm As Form, opt As OptionGroup
Set frm = Forms![frmRequisitionDetail]
Set opt = frm!OptRep
If opt.Value = 1 Then
OptMask = "ALD"
ElseIf opt.Value = 2 Then
OptMask = "AM"
ElseIf opt.Value = 3 Then
OptMask = "GMK"
ElseIf opt.Value = 4 Then
OptMask = "DR"
ElseIf opt.Value = 5 Then
OptMask = "JLE"
ElseIf opt.Value = 6 Then
OptMask = "MDL"
Else
OptMask = "*"
End If
Set opt = Nothing
Set frm = Nothing
Here is the SQL I have as the form datasource.
Code:
SELECT tblVacancyMaster.MasterID, tblVacancyMaster.PriorityID, tblVacancyMaster.Salary, tblVacancyMaster.SubNumber, tblVacancyMaster.VacancyID, afrequis.o_recruit, afrequis.o_company, tblPriorityLKU.PriorityDesc, tblStatusLKU.StatusDesc, tblVacancyLKU.VacancyDesc, afrequis.code, afrequis.desc, tblVacancyMaster.NumberVacancies, tblVacancyMaster.NumberSubmittals, afrequis.o_opendte, tblVacancyMaster.DateNeeded, (Date()-[o_opendte]) AS [Days Open], tblVacancyMaster.SourcerCode, tblVacancyMaster.EmailSent
FROM (tblVacancyLKU RIGHT JOIN (tblStatusLKU RIGHT JOIN (tblPriorityLKU RIGHT JOIN tblVacancyMaster ON tblPriorityLKU.PriorityID = tblVacancyMaster.PriorityID) ON tblStatusLKU.StatusID = tblVacancyMaster.StatusID) ON tblVacancyLKU.VacancyID = tblVacancyMaster.VacancyID) LEFT JOIN afrequis ON tblVacancyMaster.SourcerCode = afrequis.code
WHERE (((afrequis.o_recruit) [b]Like OptMask()[/b]) AND ((tblVacancyMaster.StatusID)<>2))
ORDER BY afrequis.code;
When I open the database, I keep getting Error 2427, You entered an expression that has no value.
Can anyone tell me where I am going wrong with this code?
Thanks,
Dom