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
819 Views

Similar Articles

[PageSpeed] 14

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:

typing text onto two lines (one above the other) in one cell
What is the command and syntax to do the above? Thank you. Will, Press the Alt-Enter keys at the same time in a sentence to go to a different line within the same cell. ---- Regards, John Mansfield http://www.pdbook.com "Will Naylor" wrote: > What is the command and syntax to do the above? > > Thank you. > ...

Linking Combo box to pivot table?
Hi All, I have a pivot table which has teams on the left, months on the top and a count of the calls in the data area. What I would love is that if I could have a combo box on a worksheet which when I select a team from its list it only shows me that teams data in the pivot table. Is this possible please?? -- Adam ----------- Windows 98 + Office Pro 97 You could move Team to the page area of the pivot table. Select a team, and the pivot table will only show its data. Adam wrote: > Hi All, > > I have a pivot table which has teams on the left, months on the top and a > c...

How to view the code for excel built-in functions?
Is it possible? -For example the function PMT(). thanks. No, the code is compiled, so it would likely be less than useful anyway. About the best you can do is check out the equations used in Help (see "PV"). In article <OSU3OXOBGHA.1676@TK2MSFTNGP09.phx.gbl>, "serdar" <s@s.com> wrote: > Is it possible? -For example the function PMT(). > thanks. ...

text box on exit
I have validate code on text box and want to cursor get back text box. I use Screen.ActiveControl.SetFocus, but the cusor goes to where my mouse click. Are there any way to let cursor stay in the text box until user enter valide data? Your help is great appreciated, On Wed, 12 Mar 2008 11:43:02 -0700, Souris wrote: > I have validate code on text box and want to cursor get back text box. > > I use Screen.ActiveControl.SetFocus, but the cusor goes to where my mouse > click. > > Are there any way to let cursor stay in the text box until user enter valide > data? &...

Date/Time Displayed as 07/tt/jjjj
Hi, I'm new with MS CRM and just testing it. I have a prob with all date/time fields like described in the subject of this post. Timezone is set for all users Problem occurs in all date/time fields in the web application Anyone has a clue? Regards Jan As Administrator, go to Home > Settings > there is an area in there (can't remember what its called) that enable you to change default date/time format "JanScheider" <JanScheider@discussions.microsoft.com> wrote in message news:F1F22171-AEDC-4222-A8CE-3E333B0576CA@microsoft.com... > Hi, > > I'...

List box with available queries question
I have a list box control on a form and want the list box to display all the queries within the database. The following code is what I have so far but it does not work. Any help is appreciated. SELECT [Name] FROM MSysObjects WHERE [TYPE] = 5 and LEFT([Name],1) <> "-" ORDER BY [Name]; "Billy B" <BillyB@discussions.microsoft.com> wrote in message news:F47BB77B-7B66-4860-8954-F4FE32FE7C3C@microsoft.com... >I have a list box control on a form and want the list box to display all >the > queries within the database. The following code is what...

Send
Can I eliminate the progress box, or can I configure it to close when done? What is the function of the push pin in the bottom right of the details box? -- Joseph E. Meehan 26 + 6 = 1 It's Irish Math Joseph Meehan <sligojoeS_PAM_2@hotmail.com> wrote: > Can I eliminate the progress box, or can I configure it to close > when done? Yes. On the progress box there should be a check box saying "Don't show this dialog box". Check it. > What is the function of the push pin in the bottom right of the > details box? It "tacks" t...

Combo Box 02-10-08
I have a combo box in a form, it draws it's information from a table with two fields description and price. I can bind either one to a field (control source) in my form, but I wish to bind both fields i.e. when it puts the description into say field one I want the price to go into field two simultaneously. Merv R Merv, In the after update event of the combo Me.TheControlName = Me.TheComboName.Column(1) for the second field. Jeanette Cunningham "Merv R" <Merv R@discussions.microsoft.com> wrote in message news:84FC139D-83D8-46AA-87E6-A5655F50A744@microsoft.com... &...

Full Text Index PF
We are running 3 Exchange servers in 3 separate sites. Two of which (including our main mail relay) are running Exchange 2003 while the third is still on Ex2000. Our public folder store size is roughly 3.5 GB. I am considering setting up FTI on my public folder store. Our only desire is to speed up the search results on a public contacts folder that is replicated across all 3 servers. Is FTI our best option and how much should I expect it to speed things up? We are seeing about 15-20 second searches (and sometimes longer) currently. Not horrible, but the execs want it faster. Thanks, M...

Public Folder Replication not running
We have two exchange 2000 servers in the same exchange organization, same active directory domain. We have one set of public folders that have been configured to replicate to both servers. We would create public folders on one server and then they replicate to the other server immediately (replication interval set to "always"). But last week the replication suddenly stopped for new folders, although existing ones still appear to replicate their contents. When we create a new folder on one server, and set it in system manger to replicate to the other server, replicas never appear ...

How do you display a dialog on startup?
If you want to display a modal (or modeless) dialog when your MFC application first starts up, where do you put it? (This would be a login or an informational dialog that appears on top of the main window.) I tried putting it in the OnInitialUpdate() method in my CView-derived class, but I get asserts. Thanks. In InitInstance of your app(or OnCreate of your mainwindow), you could post a custom message to your mainframe. In its handler, show the dialog. -- Ajay Kalra [MVP - VC++] ajaykalra@yahoo.com "Edward W" <EdwardW@discussions.microsoft.com> wrote in message news:...

Combine part of text from one col to another
I'm trying to combine only part of a string from one column with all th text of another column. For instance I want to create usernames to log into a network. If col has Bill and col2 has Smith I want to get just the B from col1 an combine it with col2 to make smithb in a new column. Thanks in advance -- Message posted from http://www.ExcelForum.com Try this: -- HTH, RD ============================================== Please keep all correspondence within the Group, so all may benefit! ============================================== =B1&LEFT(A1) "epac135 >" <...

unable to display inbox folder due to "invalid handle"???
Ran a scandisk that identified a couple of cluster problems, and allowed the computer to fix the problems identified . Since then, whenever trying to access email in OUTLOOK, we get the following message: "Unable to display the foler. The file c:\windows\localsettings\application data\microsoft\outlook\outlook.pst could not be accessed. The handle is invalid." What is going on? ...

Calender display
Can some one assist me? I would like to temporarely display the calender and select the date in a form and capture the desired date. I am a novice at this Charles -- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/Forums.aspx/access-forms/200711/1 If you'd like to only have the calendar appear when you need to pick a date, you can use this routine. YourTextBoxName is the name of the box that will hold the date YourCalendarName is the name of your calendar. First, place the calendar where you want it to appear on the form. Next, select the calendar and goto ...

Public folder default display
Hi, I have an Exchange server 5.5 and I make some forms used by the clients to publish information in public folders. My problem is : How create a default display (server side) for a public folder used by Outlook clients. In my case I want a chronology display. Thank you Michel ...

On startup text to speech installation keeps appearing
Dear All When I load up Excel the dialog box comes up before excel continues to load saying: "Text to Speech - This feature is not currently installed. Would you like to install it now?" I dont want to install it but this KEEPS coming up, any ideas? Thanks Adam Someone answer please !!!!! >-----Original Message----- >Dear All > >When I load up Excel the dialog box comes up before excel >continues to load saying: > >"Text to Speech - This feature is not currently >installed. Would you like to install it now?" > >I dont want to inst...

Using Rept function
I want to repeat one cells entry somewhere else in my (same) worksheet and have used the Rept function successfully. However, ifthe 1st cell (e.g. A3 is in date format like 12/12/2003, when I use the Rept A3,1 function in another cell (e.g.cell R3), it returns the date as a number (37967). What I want is for the date to be repeated exactly as is (12/12/2003 or whatever date is typed). Can anyone help please Don't use the REPT function. Just enter =A3 and apply the date format you want using Format, Cells if you do not automatically get it. -- Jim Rech Excel MVP You can't unless ...

Continuous Forms
Hi I have a subform with the records displayed in the Continuous Forms view. On each line, I have a group & a subgroup. Both fields are Combo boxes. What I am trying to do is limit the choice of subgroups to those pertaining to the group shown. I have tried putting code in the On Current event in the form to allow only the correct subgroups in the Combo box, but it seems to take the criteria for the top record & apply it to all the others. This is the code:- Dim strSQL As String strSQL = "SELECT TLK_SubGroups.PK_SubGroup, TLK_SubGroups.TXT_SubAbriv, TLK_SubGroup...

Forecast Function #2
How can I use the forecast function on columns that are not adjacent to each other, or alternately, is there another function I can use for this. Otherwise, I have to type in the whole regression line equation thusly, =AVERAGE(L3,AB3,AR3)+((((3*((L3*1998)+(AB3*2001)+(AR3*2002)))-((L3+AB3+AR3)*(1998+2001+2002))))/((3*((1998^2)+(2001^2)+(2002^2)))-((1998+2001+2002)^2))*(2003-AVERAGE(1998,2001,2002))) I'm forecasting 2003 data from 1998,2001, and 2002 data. Thanks, X ...

If Formula for displaying a message
Hi If A1 is equal to or greater than 80 but less than 89,b1 =abc. If A1 is equal to or greater than 90 but less than 99, b1 =def. If A1 is equal to or greater than 100 but less than 119,b1 =ghi-- Please help Thanks Sherees Life isa journey not a destination Try: =IF(AND(A1>80,A1<89),"abc",IF(AND(A1>=90,A1<99),"def",IF(AND(A1>100,A1<119),"ghi",""))) Micky "Sherees" wrote: > Hi > > If A1 is equal to or greater than 80 but less than 89,b1 =abc. If A1 is > equal to or greater than 90 but ...

Web Page doesn't display in e-mail.
When someone sends me web page via e-mail, the web page does not open properly. Instead, I get a bunch of lines that are embedded links in the web page. Is there anyway to have the web page open correctly when I open the e-mai? ...

Displaying daily quote changes
I am a new user to MS Money who recently migrated from Quicken. I can't seem to find a way that will give me daily quote changes in my portfolio. This is Jan. 26, 2008 and it does give me the change but its not a trading day. It also has the same data as the 1-25-08 which it should. If I try to go back to January 22, it just shows the price for the 22 but not the change. Right click in a blank area within the column headers and then click "customize current view". This should show all the fields that can be added, including the "daily change". Frank "ygold...

Check boxes and conditional formatting
I'm still working with a worksheet, and I got it so if you type or select from a list the word "TRUE" into a cell in column G, then columns A-F in that row will have their font changed to bright red. So that's figured out. But if I want to get all fancy and put a checkbox or radio button in each cell of the G column that will do the same thing (change the font color of the row to red, then back to black when unchecked) how do I do that? I got a macro to work on checking the box, although I don't know how easily I can copy and paste it all for 1500+ rows) but I...

Problem replicating Public folders
We have two Exchange Servers in the organization. One is running Exchange Server 2003 Enterprise (Server A) and the other has Exchange Server 2003 Standard (Server B), both fully patched. Contents of some public folders are being successfully replicated between the two folder. For some reason, the other folders are not. When go to the Replication Tab of these Public Folders, I get the following error message: ---------------------------------------------------------------------------------------- An unexpected, unknown error has occurred. MAPI, or an unspecified service provider. ID no:...

can auto text be used in excel
can auto text be used in excell like it can in word? You can enter data in a table in Word then transfer it to Excel. "Me" wrote: > can auto text be used in excell like it can in word? ...