Public Function to display in text box

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!




0
Utf
5/6/2010 12:38:01 AM
access.formscoding 7493 articles. 0 followers. Follow

8 Replies
767 Views

Similar Articles

[PageSpeed] 44

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. Stacy" <david_d_stacy@msn.com.(remove_this_part).> wrote in message
news:CA4E119A-7936-4F38-829A-1A8129F7305C@microsoft.com...
> 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!
>
>
>
>



0
Jeanette
5/6/2010 1:16:39 AM
Hi Jeanette,
I entered that into the control source property and that produces the #Name? 
error.



"Jeanette Cunningham" wrote:

> 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. Stacy" <david_d_stacy@msn.com.(remove_this_part).> wrote in message
> news:CA4E119A-7936-4F38-829A-1A8129F7305C@microsoft.com...
> > 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!
> >
> >
> >
> >
> 
> 
> 
> .
> 
0
Utf
5/6/2010 2:10:01 AM
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. Stacy" <david_d_stacy@msn.com.(remove_this_part).> wrote in message
news:E5094B80-5BCC-492F-BDA8-FF7F698A5541@microsoft.com...
> Hi Jeanette,
> I entered that into the control source property and that produces the
> #Name?
> error.
>
>
>
> "Jeanette Cunningham" wrote:
>
>> 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. Stacy" <david_d_stacy@msn.com.(remove_this_part).> wrote in message
>> news:CA4E119A-7936-4F38-829A-1A8129F7305C@microsoft.com...
>> > 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!
>> >
>> >
>> >
>> >
>>
>>
>>
>> .
>>



0
Jeanette
5/6/2010 2:29:14 AM
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.



"D. Stacy" wrote:

> Hi Jeanette,
> I entered that into the control source property and that produces the #Name? 
> error.
> 
> 
> 
> "Jeanette Cunningham" wrote:
> 
> > 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. Stacy" <david_d_stacy@msn.com.(remove_this_part).> wrote in message
> > news:CA4E119A-7936-4F38-829A-1A8129F7305C@microsoft.com...
> > > 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!
> > >
> > >
> > >
> > >
> > 
> > 
> > 
> > .
> > 
0
Utf
5/6/2010 2:35:01 AM
On Wed, 5 May 2010 19:35:01 -0700, D. Stacy
<david_d_stacy@msn.com.(remove_this_part).> wrote:

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

             John W. Vinson [MVP]
0
John
5/6/2010 3:17:34 AM
Try using Me.Recalc in the after update of the combo.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia

"D. Stacy" <david_d_stacy@msn.com.(remove_this_part).> wrote in message 
news:FB92BB87-A98F-42D3-8B46-ACAF876745E4@microsoft.com...
>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.
>
>
>
> "D. Stacy" wrote:
>
>> Hi Jeanette,
>> I entered that into the control source property and that produces the 
>> #Name?
>> error.
>>
>>
>>
>> "Jeanette Cunningham" wrote:
>>
>> > 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. Stacy" <david_d_stacy@msn.com.(remove_this_part).> wrote in message
>> > news:CA4E119A-7936-4F38-829A-1A8129F7305C@microsoft.com...
>> > > 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!
>> > >
>> > >
>> > >
>> > >
>> >
>> >
>> >
>> > .
>> > 


0
Jeanette
5/6/2010 3:35:06 AM
"D. Stacy" <david_d_stacy@msn.com.(remove_this_part).> wrote in message 
news:FB92BB87-A98F-42D3-8B46-ACAF876745E4@microsoft.com...
>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)


0
Stuart
5/6/2010 9:48:23 AM
D. Stacy <david_d_stacy@msn.com.(remove_this_part).> wrote:

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


Since the variable returned by the function is local to the
function and never set by the function, its initial value,
which is 0, is all the function can ever return.

Where does your original function that "produces a variable 
as a double" store that variable's value.  For your two
functions to work together, the varaible must be declared in
a place that is available to both functions.  Assuming both
functions are in the same module, the variable needs to be
declared in the module's deckarations section (at the top of
the module, before any Sub or Function statements):

Private CurrentWork_GPCI As Double
  . . .
Public Function SetCurrentWork_GPCI()(...
	  , , ,
	CurrentWork_GPCI = something
End Function

Public Function GetCurrentWork_GPCI() As Double
    GetCurrentWork_GPCI = CurrentWork_GPCI    
End Function

-- 
Marsh
MVP [MS Access]
0
Marshall
5/6/2010 12:49:05 PM
Reply:

Similar Artilces:

Display Quote Number on Order
Hello, I am trying to display the field named quotenumber on the Order form. I see that there is already a field mapped from Quote.quotenumber to SalesOrder.quoteidname. However, when I go into system customization, I cannot choose to view the quoteidname field in the form. Is this a bug or by design? By design. When the quoteid field is added to the screen, it will actually show the name of the quote. That's about the closest you will be able to get in terms of displaying data from the Quote. Matt Parks MVP - Microsoft CRM ---------------------------------------- --------------------...

Excel Function VLOOKUP
Hi, I'm having trouble looking up a table of "Names". The table deifene below is called ROL_IS and list hundred of other defined tables. Error where: =VLOOKUP(A33,VLOOKUP(CUR_MON,ROL_IS,3,FALSE),2,FALSE) but no errors where =VLOOKUP(A33,ACT_IS,2,FALSE) or =VLOOKUP(CUR_MON,ROL_IS,3,FALSE) ANS: ACT_IS The array function in VLOOKUP appears not to converting formula to NAME. If anyone knows or needs further details if would be appreciated. Thanks Elizabet -- Message posted from http://www.ExcelForum.com If I understand you correctly =VLOOKUP(A33,INDIRECT(VLOOKU...

catch the incoming message event on a public folder
Hello, Is it possible to catch the incoming message event when a new message arrives into a public folder, and run an external exe file? Thanks. ...

adding number only if CDN is displayed in next cell
I have a list of sales for Canadian and US Customers. I marked in the column besides the sales amount if it is CDN or US. How can I add the CDN or the US Sales only. Thanks for your help. Use SUMIF() See HELP for details -- Kind regards, Niek Otten "ED" <ED@discussions.microsoft.com> wrote in message news:7B61595A-17DD-4254-A46F-A8D26BF0D9AB@microsoft.com... >I have a list of sales for Canadian and US Customers. I marked in the >column > besides the sales amount if it is CDN or US. > > How can I add the CDN or the US Sales only. > > Thanks for y...

Public folder administration issue(s)
I just started working in an environment which has the following issue(s). The overall problem is that I can't administer permissions on Public Folders in a Exchange 2000 environment. The public folders are accessible for viewing and adding items, et Characteristics are as follows From Outlook clients, no permissions tab is available when right-clicking on a public folder and selecting properties In ESM when in the Folders container under the Administrative Group I try to expand the Public Folders folder and receive the following error "The connection was refused. Ensure that your HT...

Close Database Function?
I want to use task scheduler to open an Access DB, run a macro that updates a table from an external source, then close the DB and Access. I do not use any forms on this database, just one table and one macro. So I guess my needs are as follows: 1. Automatically execute 'My_Macro' when the DB is opened from Task Scheduler. My Scheduled Task uses the /X switch to specify and execute the Macro - my main problem is determining how to programatically close the DB and Access. I would like to continue using the command line method of executing the macro if possible so that I can m...

Public folders in Active directory
Due to a corrupt Pub1.edb I have deleted the bad edb and stm file and created new blank files. My next step will be to re-create the public folder structure but before I do that I need to know how AD treats public folders and if I should manual delete the public folders in AD before I start re-creating folders in the new public folders On Thu, 25 Jan 2007 14:07:02 -0800, RP in the Midwest <RPintheMidwest@discussions.microsoft.com> wrote: >Due to a corrupt Pub1.edb I have deleted the bad edb and stm file and created >new blank files. My next step will be to re-create the pu...

Duplicating text in Word 2007
Hi, I've got a template I previously did for Word 2003 where I basically had several {macrobutton nomacro Type something here} fields. Now, in Word 2007, I see I have the option to actually add a Text content control, which looks fantastic :) BUT, is there a way of making it so that if I type something in one content control, the same text value is automatically added into the second one as well? Or even a third? How can I do that? Found out that if I insert a comment field and copy that field, they both work as I want! Yay! But, the comment field I insert via the Insert...

Passing an Array created in a Function or Subprocedure back to the calling Subprocedure
I want to have a Function or Subprocedure that can create an array with 52 specific values in it. I then want to call this Function or Subprocedure from a main Subprocedure and be able to access the contents of the array. Everything can be of type variant for the purposes of this exercise. Can anybody help, please? This worked ok for me: Option Explicit Sub testme() Dim myArr As Variant Dim iCtr As Long myArr = BuildArray(myArr) For iCtr = LBound(myArr) To UBound(myArr) MsgBox iCtr & ". " & myArr(iCtr) Next iCtr End Sub Function Buil...

how do i display the sort arrows in column headers in access 2007
I can't seem to find where I can turn on the sort arrows in table column headers. Any advice? Where are the column headers? In a table, query, form - data sheet - other? Some where else? Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia "KenBob2" <KenBob2@discussions.microsoft.com> wrote in message news:5280AF5F-F673-48D4-8C31-0051BF53A3F4@microsoft.com... >I can't seem to find where I can turn on the sort arrows in table column > headers. Any advice? I think it's: - office button (that upper left button) - access o...

Look Up and Display set data
I have an annual leave Tracker / Sickness / Training spreadsheet. On each day if a member of staff is Sick S is entered if on annual leave (holiday) H is entered and T for training. What I would like to do is add a function to display set data. For Example in Column A I have the names of all staff. Column B their managers name then in the other columns C, D, E etc I have dates of the year. Is there a way I can display for example / create a page where I can ask Excel to display say for example activity for a member of staff in S (Sickness) state, or all details. Or for example can I run ...

Outlook displays offline icon, but really online.
So i am connected to a server, not using cached mode. When i open outlook it connects and shows that im online in the status bar, but in the task bar it displays the offline icon. How can fix it? The last thing I remember doing before this problem began is switching to cached mode to test spam filter. I switch offline, then back to online but the icon did not change back. nm fixed it ...

Custum Cell Format
I have an array formula which automatically summarizes all available values of a certain column, in ascending order. The summary is fixed to a maximum of 8 cells and in many cases it uses less than the available 8 columns. Is it possible to format the cells by showing a 0 when the result/cell is empty In other cells in the sheet the cells show empty instead of a zero by using the custom format of 0;-0;"" Now I want an empty cell to show 0 Thanks, W -- willemeulen Blink1 *Willem van der Meulen* BSc Soil & Water Eng (Netherlands) ----------------------------------------...

Cannot insert pictures in Pubisher. Text also disappears!
I have worked for several hours on a newsletter, now everything changes. Photos overlay on print and print disappears. Read the third FAQ here http://ed.mvps.org/Static.aspx?=Publisher/FAQs -- Mary Sauer MSFT MVP http://office.microsoft.com/ http://msauer.mvps.org/ news://msnews.microsoft.com http://officebeta.iponet.net/en-us/publisher/FX100649111033.aspx "Disgusted" <Disgusted@discussions.microsoft.com> wrote in message news:421A5715-4D0A-4EC9-8C94-941B4B9DBA9F@microsoft.com... >I have worked for several hours on a newsletter, now everything changes. > Photos over...

Dynamic cell references in cube functions
What is the syntax to make for instance the cubevalue function pick up parameter values from the spreadsheet so my report becomes dynamic? I have the following statement: =CUBEVALUE("datasource";"[Measures].[Volume]";"[Time].[YM].[YM].[2007].[200710]") I want to make a dynamic report so that the year [2007] and the month [200710] changes according to dates I put into the spreadsheet (for instance today()) so the report automatically updates the query to current time periode. Thanks in advance! I don't know cubevalue and it isn't in Excel help on ...

Saving Outlook Email As Text File Extract
Hello Outlook Group: I'm normally an Access and Excel VBA programmer, but my client wants me to scrape the text from a select email address and insert it into an Access memo column. Does anyone know how to configure Outlook (VBA approach would be fine) so that when an email is received in a selected account, the message would also be extracted to a directory as a text file and then the Outlook message would be moved to some history folder. Once the text file exists in a predefined folder , I will just have Access periodically check the folder for files, grab the text, ...

ShellExecute to display windows property dialog
Hi EveryBody, This group has helped earlier to solve my problems and I hope I may get some help this time as well. I want to dispaly the windows property dialog for files through my application developed using VC6.0. I am using the function ShellExecuteEx with the "properties" verb to display the dialog. However, I am facing a problem while displaying the dialog for .tiff files on Win98/WinME systems. I tried putting the thing in a separate thread as I read somewhere that ot may help, but no success. I tired using the function ShellExecute, but it does not display the dialog. Can a...

via 2000 Access to retrievel data from 2000 outlook public folder
Dear Helpers, I am using MS 2000 outlook. My company stores all the products and service guidelines in the public folder located at outlook. Every week there are updates of products and service guidelines where I need to check for those guidelines to support the sales teams and back office. The structure is as follows: +Public Folder +Products Folder +Product 100 +Product 101 +Product 102……. +Services Folder +Service 100 +Service 101 +Service 102…… Each product or service is made into a new subfolder and there further subfolders when there are product mo...

Switching to a shared Calendar in a Public Folder changes the input locale?
Hello, We have the Outlook client installed in English everywhere but many users have keyboards with layouts for different languages. When some users go to certain public folders and open, e.g., a shared calendar, the language bar changes from EN to another layout. It's a soon as they click on the Calendar tree - they don't even have to open an item. Does the top-level folder take the layout of the creator? How can it be changed, and avoided in future please? Thanks, - Alan. ...

Text Boxes are not printing
Version: 2008 Operating System: Mac OS X 10.4 (Tiger) Processor: Power PC Installed Office 2008 over Office v.X and worked on a monthly newsletter as a new document,using Word, but copying and pasting from the previous month before proceeding to make changes. Print preview looked alright but the text boxes did not print. Is it a printer problem or a doc problem? It could be a problem with the printer, or it could be a wrong setting in Word. First of all, make sure you are using the latest driver for your printer; that is a useful precaution, as you use your printer with a number of applicati...

Undefined function 'Format$' in expression.
Dear all, I've converted my db from 97 to 2k. When I tried to run a Query, above mentioned message pops up. It seems like there's no such function of Formst$ (change date format) in Access2k? Or it's about conversion error? Also, I can view my VB codes after conversion. Appreciate someone to help. Thanks. Hi Mike, This normally means something has gone with references in the VBA project. See http://members.rogers.com/douglas.j.steele/AccessReferenceErrors.html for details and how to fix it. On Wed, 1 Oct 2003 03:24:26 -0700, "Mike Oh" <mike_oh@memwire.com> ...

Invoking Function from Watch Window
Hello All I have a question about VC++ debuging. VS debugger provides that you can execute certain type of function function from the watch window for debugging purpose. I am having problem with executing a function from any module other than the module containg the function. For e.g. class Test { int test() { return 10; } }; void main() { Test myTest; } Now if i add the watch t.test() it works fine. but when the class test is plcaed in a different DLL module the watch can not find the code. According to MSDN module can be specified as {,,ModuleName}expression. But ...

Public and system folder migration
hi I have a small single site, i introduced 2003 exchange server and moved mailboxes over to 2003 , similarly created a relica on the new exchange 2003 server. WHich other system folders do i have to move over or replicated over to 2003 server, before i could decommision the exchnage 5.5 server. thanks Hello Please peruse the following KB Articles: 822450 How to remove the last Exchange Server 5.5 computer from an Exchange : http://support.microsoft.com/?id=822450 327779 How To Convert from Mixed Mode to Native Mode in Exchange : http://support.microsoft.com/?id=327779 Regards -- ...

adding url in rich text
Hi, When i type a url into the body of a rich text email, such a www.blah... when the email is sent it automatially inserts.. "HYPERLINK "www,blah..." in the message, in front of the url i originally typed., and then th actual url after it. This wasn't happening before, does anyone know how to stop it? many thank ----------------------------------------------- ~~ Message posted from http://www.ExcelTip.com ~~View and post usenet messages directly from http://www.ExcelForum.com ...

zoom box on saved html page?
is there a way to put a real zoom box to zoom in on a largeish sheet so when i save it as a web page, ppl can zoom in and out out the page please? please bare in mind im VERY new at this, but would love to do this as when i create a sheet i am zoomed in to 50% and i can read everything, but when i save the page its 100% and way to small so would like to be able to zoom in and out on the html page just like i can in excel, any help appreciated, thanks K ...