Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / New Users / April 2005

Tip: Looking for answers? Try searching our database.

passing parameters

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
GSteven - 12 Apr 2005 15:39 GMT
I'm missing something. Fairly new to Access and trying to build a selection
application. I'm presenting a list of customers in a continuous form
"ChooseCust". This list includes some information that would allow a user to
place a check in a checkbox if they want that customer on a report
"CustReport". I also wanted the user to select which salesperson was to
follow up with the chosen customers.

The first part I have working OK. The checkbox is tied back to a yes/no
field in the underlying table and when the "preview report" button is
clicked the report is called up with just the checked customers. The problem
I'm having is how to get the desired salesperson's name on the report. I'm
presenting the list of sales people in a combo box with row source tied to a
query "AllSalesPeople". I have a procedure for "after update" which then
assigns the value chosen to a public var named strSPerson. This var is
declred public in the declarations section of the form. Question is how do I
get this value passed to the report. I can step through the code (using
debug) and verify that the strSPerson is actually being assigned the correct
chosen value but as soon as I step 'out' of the procedure the var strSPerson
becomes null again. Needless to say I cannot "see" this variable from the
report when it is opened.

Can any of you experts see where I'm going wrong?

tia
Steve
Ofer - 12 Apr 2005 16:08 GMT
Ho Steve
Declare strSPerson as Global in a Module, and than you
wont lose the value after you close the form. and you can
use it on the report.
When you declare A variable on the form you can ue it only
in the form.

>-----Original Message-----
>I'm missing something. Fairly new to Access and trying to build a selection
[quoted text clipped - 24 lines]
>
>.
GSteven - 12 Apr 2005 16:33 GMT
OK, so I create a new module called "InitSPerson" and declare strSPerson
global (Global strSPerson as String). So then I can 'call' this proc by
asigning it to the 'on open' event of the form, right? At least that's where
my thinking leads me. So I don't see a way to 'call' the InitSPerson module.
I feel like such a newbie.

Steve

> Ho Steve
> Declare strSPerson as Global in a Module, and than you
[quoted text clipped - 48 lines]
>>
>>.
Ofer - 12 Apr 2005 16:45 GMT
1. You declared strSPerson as Global
2. After you update the name of the saleperson assign that
name to strSPerson that you declared
3. On the print property of the report assign tha value of
strSPerson to the field on the report.
or create a function that return the value of strSPerson
and on controlsource of the field on the report write =
and the name of the function you created

>-----Original Message-----
>OK, so I create a new module called "InitSPerson" and declare strSPerson
[quoted text clipped - 59 lines]
>
>.
GSteven - 12 Apr 2005 17:42 GMT
Thank you very much for your replies.

OK, I place a textbox on my report and set control source to "strSPerson" or
"=strSPerson" and when I run report I get a dialog asking for strSPerson.

Decide on second suggestion. Go to module tab of database and click 'new'.
Name module 'GetSP' and contains the lines 'compare database'. 'Public
function GetSP(salper as string)', 'salper = InitSPerson.strSPerson' & 'End
Function'.
   Now I cannot see the function in the builder dialog box therefore cannot
choose the function.

???

> 1. You declared strSPerson as Global
> 2. After you update the name of the saleperson assign that
[quoted text clipped - 77 lines]
>>
>>.
Ofer - 12 Apr 2005 18:14 GMT
You mixed it up
lets try one way:

1. declared strSPerson as Global variable (You did that)
2. After you update the name of the saleperson assign that
name to strSPerson Variable that you declared (Check with
the Debuger that the variable has the value)
3. create a function that return the value of strSPerson

Function GlobstrSPerson() as string
    '***************************************************
    ' This function will return the Name of the sales man
    '***************************************************
    GlobstrSPerson = strSPerson
end Function

4. On control source of the field on the report write:
"=GlobstrSPerson()"

>-----Original Message-----
>Thank you very much for your replies.
[quoted text clipped - 94 lines]
>
>.
GSteven - 12 Apr 2005 18:39 GMT
see below

1. declared strSPerson as Global variable (You did that) (Yes,
successfully)

2. After you update the name of the saleperson assign that name to
strSPerson Variable that you declared (Check with the Debuger that the
variable has the value) (debugger shows value was assigned to strSPerson as
string type under InitSPerson context)

3. create a function that return the value of strSPerson

Function GlobstrSPerson() as string
    '***************************************************
    ' This function will return the Name of the sales man
    '***************************************************
    GlobstrSPerson = strSPerson
end Function

(Done exactly as described)

4. On control source of the field on the report write: "=GlobstrSPerson()"

(done, when I run report I get dialog asking for a value for GlobstrSPerson
and I can either leave it blank or enter some string. In either case when
the report comes up the field has #Name? in it.)

Furthermore when I'm in debug immediate window and enter ? GlobstrSPerson()
I get a compile error "Expected variable or procedure, not module". Does
this shed any more light on it?

thanks again for your patience
Steve

>>-----Original Message-----
>>Thank you very much for your replies.
[quoted text clipped - 109 lines]
>>
>>.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.