Solved

how i send to a globel model a string and how i get it back in access 2010

Posted on 2011-03-08
5
199 Views
Last Modified: 2012-05-11
hi

i have in a form this formula

how can i send it to a globel model function and how i get it back from the globel model
Dim strFormName as String
Set strFormName = {Current Form Name}

Open in new window

0
Comment
Question by:bill201
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 35072446
Technically you don't "Get" or "Send" values to/from a Module.

You typically can retrieve a Public Variable using a Public Function.
...And store values in public variables.

Something like this in a Public Module:

Public lngpubCustomerID as long

Public Function GetCustomerID () as long
    GetCustomerID =lngpubCustomerID
End function

Now you can set the public variable from anywhere in your project, something like this:
lngpubCustomerID =me.cboCustomerID
...Then retrieve it with this:

SomeThing=GetCustomerID()


Note that you may also have to implement a system to "reset" the variable.

The danger here is that you must tightly control where, when and how you set the Variable, or things could get confusing.


JeffCoachman
0
 

Author Comment

by:bill201
ID: 35089887
Thanks for Your Answer sorry for the delay i was outside the town...


iry the code that you give but its not working

this is my code in the form that i store the variable
Public Sub Command21_Click()
Dim strFormName As String
strFormName = Me.Name
GetFormNameSt = strFormName
End Sub

and this is my public module
Option Compare Database
Public GetFormNameSt As String
Public Function GetFormName() As String

GetFormName = GetFormNameSt


End Function

and in the other form where i want to retrive the variable i wrote this code in a command buttan
Private Sub Command0_Click()
Dim b
b = GetFormNameSt
MsgBox b
End Sub

but the problem that i get a blank msgbox without the form name  
0
 
LVL 74

Accepted Solution

by:
Jeffrey Coachman earned 500 total points
ID: 35097860
Your naming is a bit confusing.
It seems like this line:
GetFormNameSt = strFormName
You are trying to assign the value of the variable named strFormName to a variable named GetFormNameSt
But the prefix "Get" is typically used to refer to a *function*, not a variable.
You cannot assign a variable to a function.
A function will "return" a value.

I also don't see the need for the "Intermediate" variables (unless you are using them somewhere else...)

If your ultimate goal is to store the name of a form and retrieve it in another form, then you really only need to reference the public variable:
Msgbox YourPublicVarialbe

But in the interest of completeness (and because you cant use a Public variable as criteria for a query), I will show you both methods in the attached sample

;-)

JeffCoachman




Database47.mdb
0
 

Author Comment

by:bill201
ID: 35099344
thanks thousand times for your excellent and detailed answer i'm grateful for you, I'm more than supplied from your professional answer and it is a pity that i don't can to give your more then 500 points...


Bill
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 35105021
Thanks for the kind words
I'm just glad I was able to help.

;-)

jeff
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question