How to invoke function on a form

  • Thread starter Thread starter Dale C Gray
  • Start date Start date
D

Dale C Gray

Ok this is probably elementry..but I can't figure out how to do this:

Here is the function:
Function fExtractStr(ByVal strInString As String) As String

Works fine from the debug window: fExtractStr("ab789") returns "ab"

But I want to call it from a form with the control name being AHC, control
source PHN...
Tried fExtractStr([AHC]) and fExtractStr("[AHC]")...to no avail. Is it
fExtractStr(strinString:=[AHC])?

Access 97
Thanks for your help.
 
Is your intent to extract from the value of the control AHC? If yes:

fExtractStr(Me.AHC.Value)
 
Yes thats what I want to do, so I can't reference from the properties box
i.e. =fExtractStr([AHC]), I have to reference it as an event on the
afterupdate property?
and Thanks Ken

Ken Snell said:
Is your intent to extract from the value of the control AHC? If yes:

fExtractStr(Me.AHC.Value)
--
Ken Snell
<MS ACCESS MVP>

Dale C Gray said:
Ok this is probably elementry..but I can't figure out how to do this:

Here is the function:
Function fExtractStr(ByVal strInString As String) As String

Works fine from the debug window: fExtractStr("ab789") returns "ab"

But I want to call it from a form with the control name being AHC, control
source PHN...
Tried fExtractStr([AHC]) and fExtractStr("[AHC]")...to no avail. Is it
fExtractStr(strinString:=[AHC])?

Access 97
Thanks for your help.
 
For which control do you want to use this as an expression in the control
source? You can do this in a control source, but when you do that control
cannot also be bound to a field in the form's record source.

If you want your control to be bound to a field and you want to put a value
into that control, then yes you need to do it via AfterUpdate event coding.

--
Ken Snell
<MS ACCESS MVP>

Dale C Gray said:
Yes thats what I want to do, so I can't reference from the properties box
i.e. =fExtractStr([AHC]), I have to reference it as an event on the
afterupdate property?
and Thanks Ken

Ken Snell said:
Is your intent to extract from the value of the control AHC? If yes:

fExtractStr(Me.AHC.Value)
--
Ken Snell
<MS ACCESS MVP>

Dale C Gray said:
Ok this is probably elementry..but I can't figure out how to do this:

Here is the function:
Function fExtractStr(ByVal strInString As String) As String

Works fine from the debug window: fExtractStr("ab789") returns "ab"

But I want to call it from a form with the control name being AHC, control
source PHN...
Tried fExtractStr([AHC]) and fExtractStr("[AHC]")...to no avail. Is it
fExtractStr(strinString:=[AHC])?

Access 97
Thanks for your help.
 
Sorry, guess I'm not being clear. This is a control on a form. I am trying
to call the function from a module (heard there was less overhead this way?)
and I wanted to reference the function from the controls properties sheet
i.e.
After update..... =fExtractStr([AHC]) rather than as an [event procedure],
which I can do, but that was my question if I wanted to use the syntax above
to call the function rather than
have it as an event.


Ken Snell said:
For which control do you want to use this as an expression in the control
source? You can do this in a control source, but when you do that control
cannot also be bound to a field in the form's record source.

If you want your control to be bound to a field and you want to put a value
into that control, then yes you need to do it via AfterUpdate event coding.

--
Ken Snell
<MS ACCESS MVP>

Dale C Gray said:
Yes thats what I want to do, so I can't reference from the properties box
i.e. =fExtractStr([AHC]), I have to reference it as an event on the
afterupdate property?
and Thanks Ken

Ken Snell said:
Is your intent to extract from the value of the control AHC? If yes:

fExtractStr(Me.AHC.Value)
--
Ken Snell
<MS ACCESS MVP>

Ok this is probably elementry..but I can't figure out how to do this:

Here is the function:
Function fExtractStr(ByVal strInString As String) As String

Works fine from the debug window: fExtractStr("ab789") returns "ab"

But I want to call it from a form with the control name being AHC, control
source PHN...
Tried fExtractStr([AHC]) and fExtractStr("[AHC]")...to no avail. Is it
fExtractStr(strinString:=[AHC])?

Access 97
Thanks for your help.
 
Back
Top