Public Function to display in text box

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!
 
J

Jeanette Cunningham

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
 
D

D. Stacy

Hi Jeanette,
I entered that into the control source property and that produces the #Name?
error.
 
J

Jeanette Cunningham

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
 
D

D. Stacy

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.
 
J

John W. Vinson

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

Requery the textbox in the AfterUpdate event of the combo.
 
J

Jeanette Cunningham

Try using Me.Recalc in the after update of the combo.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
S

Stuart McCall

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top