Public Function to display in text box

  • Thread starter Thread starter D. Stacy
  • Start date Start date
D

D. Stacy

Have public function (loaded in the global module) that produces a variable
as a double.

That all works fine as evidenced by the debug.print method in the immediate
window.

I desire to have the current value of the variable displayed in a text box.

I created a callback function (loaded in global module) that looks like:

Public Function GetCurrentWork_GPCI() As Double
Dim CurrentWork_GPCI As Double

GetCurrentWork_GPCI = CurrentWork_GPCI

End Function


I can't figure out how to make it display; I've currently got the control
source property set to =GetCurrentWork_GPCI(), but that just displays a 0.


Please help!
 
Stacy,
just use the public function you created earlier, and importantly, you need
to tell it what value to use for lCriteria.


=FindGPCI_Work(Me!txtLocality_ID)

The above is what goes in the control source for the textbox.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
Hi Jeanette,
I entered that into the control source property and that produces the #Name?
error.
 
Check that you are using the exactly correct name for that public function
and that FindGPCI_Work(Me!txtLocality_ID) is still a public function in a
standard module.

Or we can do it like this:

----------------------
Private Sub Combo0_AfterUpdate()
Dim lCriteria As Long
Dim lngReturn as Long

lCriteria = Me!txtLocality_ID
lngReturn = FindGPCI_Work (lCriteria)
Me.TextboxName = nz(lngReturn,0)
End Sub
----------------------


Note: replace TextboxName with the name of your textbox


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
I got that issue resolved (typing problem!).

Now I need to to just get the txt box to refresh after each change of the
combo box.
 
Try using Me.Recalc in the after update of the combo.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
D. Stacy said:
I got that issue resolved (typing problem!).

Now I need to to just get the txt box to refresh after each change of the
combo box.

I suggest 'pushing' the value into the textbox from the combo, rather than
using an expression in the textbox's controlsource to 'pull' the value (I
think this is what John V meant). Try blanking the textbox's controlsource
and put this code in the combo's AfterUpdate event:

Me!TextboxName = FindGPCI_Work(Me!txtLocality_ID)
 
Back
Top