Topics Search

Using LIKE with a function

Using LIKE with a function
Views: 4
Please can someone tell me if its possible to use LIKE and a function as a query criteria?

My function is:

Public Function User()

User = VBA.Environ("UserName") End Function

And my query is:

SELECT tbl_REF_Reminder.Type, tbl_REF_Reminder.PIC, tbl_REF_RMOPIC.[UN Code], tbl_REF_RMOPIC.[AG Code], tbl_REF_Reminder.Agent, tbl_REF_Reminder.DueDate, tbl_REF_Reminder.RemindStatus, tbl_REF_UID.UserID, tbl_REF_RMOPIC.[Agency Name] AS Agency

FROM (tbl_REF_Reminder INNER JOIN tbl_REF_RMOPIC ON tbl_REF_Reminder.Agent = tbl_REF_RMOPIC.[UN Code]) INNER JOIN tbl_REF_UID ON tbl_REF_RMOPIC.[PIC Name] = tbl_REF_UID.Name WHERE (((tbl_REF_Reminder.PIC) Like User()) AND ((tbl_REF_Reminder.DueDate) Between Format(Now()-2,'dd/mm/yyyy') And Format(Now(),'dd/mm/yyyy')) AND ((tbl_REF_Reminder.RemindStatus)=-1));

When I try as per above I get no results. If I add *User()* I get an invalid operator error.

I need to use LIKE as there may be multiple users in the PIC field
Sponsored Links:

More topics

 

Where called from

Preview
I have several functions.say a, b, c, d. Each one calls the same function.say X. How do I get function X to know which function called it.without putting the specific calling function's name in the call to function X ?
 

Want function to get current function name

Preview
I am developing an all-purpose error handler. As I see it, the "ideal" function would look like this:

Public Function Foo()
On Error GoTo er
'Code goes here.
ex: 'Cleanup code, closing open objects, etc.
Exit Function
er:
erf 'An error handling function, which writes this function's name
'and error stats to a table, then returns here.
MsgBox Err.Description 'Allows stepping through code in this function.
Resume ex 'Gets cleanup code.
End Function

The only issue I'm having is having to pass the current function name in to my error handler. Does anyone know a way to get this systematically
 

Multiple Controls on one sub

Preview
I have 10 check boxes. I want all of them to run a function after update. Is there a way to put all 10 on one sub, instead of having to have a sub for each box?

Instead of

Sub Chk1_AfterUpdate() Function End Sub Sub Chk2_AfterUpdate() Function End Sub

etc.
Could I have something like

Sub Chk1 through Chk10_AfterUpdate() Function End Sub
 

Want a brainteaser? Here's one...

Preview
Imagine functions (as in coding): there is a function call, to each function there are parameters and whereas the names and the amount of parameters is specific to a function, the value of that parameters is specific to each individual function call.

For example:
Add (Number1,Number2)
ADD = function
Number1 & Number2 = parameters specific to the function

Add (5,3) = function call
where the numbers 5 and 3 are parameters specific to the function call

-

What I would like is a datamodel that can do this: if I add a new function, it should present me with the parameters specific for that function, but the values for those parameters should be different for each 'function call'. I'm really struggeling with this one and I'm in need of some
 

Want a brainteaser? Here's one...

Preview
Imagine functions (as in coding): there is a function call, to each function there are parameters and whereas the names and the amount of parameters is specific to a function, the value of that parameters is specific to each individual function call.

For example:
Add (Number1,Number2)
ADD = function
Number1 & Number2 = parameters specific to the function

Add (5,3) = function call
where the numbers 5 and 3 are parameters specific to the function call

-

What I would like is a datamodel that can do this: if I add a new function, it should present me with the parameters specific for that function, but the values for those parameters should be different for each 'function call'. I'm really struggeling with this one and I'm in need of some
 

=CurrentUser()

Preview
Trying to get us onto accdb from mdb and of course have to resolve the user login.

Can I take ownership of the above function?
I understand this is a function Access "owns" or am I

Nearly all of our problems would be resolved if I can get into this function and have it look to the new login Form I will create to get the CurrentUser() rather then the mdw file I assume it currently looks for.

If I can't do this then I must seach for all references to this function and replace same with a new function I create say, =TeamMemberLogged
 

How do you use a Function inside another Function?

Preview
Forum,

I have created a Function to perform a task (delete records) and want this to be actioned within another function.

How do I get this to happen ? DoCmd ?

Here is an extract of the main procedure and the function I want to get to work is FuncDeleteRecord(some variables)


If RepayFreq = "Fortnightly" Then
'FuncDeleteRecord("TblLateFeeCalculated", "LDPK", "LoanID")
Do Until Date <= CommenceDate

Appreciate any advice
 

InsertAtCursor function

Preview
Allen Browne created a VBA Function named[LINK] By pressing a key combination it will insert text at the cursor position on a form. Does anyone know of a simple database that uses this function? I would like to view the coding and try to figure out how to incorporate this function into a database. I am having difficulty with Arguments, Compile Errors, etc.
 

Passing a reference to a control on a subform to a function

Preview
I was wondering if someone could give me a hand with this one.

I have referenced a control on a form from a function in a module using this:
Forms(frm.Name).Controls(ctl.Name).Value

The function looks like this:
Function(frm as form, ctl as control)

The function call looks like this:
Call Function(me, me.ctl)

This all works fine but I cannot work out how to do the same thing except referencing the control in a subform, i.e. what do you pass to the function and how do you reference it in the function?

I have tried everything I can think of, stuff like.

Forms(frmParent.name).Forms(frmSubform.name).Contr ols(ctl.name).value

and passing it like this.

Call Function(me.parent, me, me.ctl)
Function(frmParent as form, frmSubform as form, ctl as control)
 

Collection function

Preview
I am trying to figure out what a below function would be doing:

Public Function Clrclct(clct As Collection)
For I = 1 To clct.Count
clct.Remove 1
Next
End Function

I can only add that it's later being used while exporting tables from access to excel.