Passing Two Argument in OpenFrom

K

Ken Hudson

I got some assistance here yesterday with passing one argument to a form.
Like most cases, you always wnat one more thing.
In addition to passing a hard coded argument, I want to pass a variable
argument.
I have used an InputBox to capture the variable.
How do I then pass the hard coded and varibale arguments to the form?

Private Sub cmdOpenActiveProjectsForm_Click()
On Error GoTo Err_cmdOpenActiveProjectsForm_Click

Dim stDocName As String
Dim stLinkCriteria As String
Dim stEmpNumber
stEmpNumber = InputBox("Enter your employee number.")
stLinkCriteria = "intStatus = 1," & stEmpNumber (This does not work.)
stDocName = "frmProjectsPM"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdOpenActiveProjectsForm_Click:
Exit Sub

Err_cmdOpenActiveProjectsForm_Click:
MsgBox Err.Description
Resume Exit_cmdOpenActiveProjectsForm_Click

End Sub
 
K

Ken Hudson

Hi Roger,
If you are still "listening", I have a follow up coding question.
I have two switchboards, one for administrators and one for others, that
subsequently open my projects form.
When I open the administrator switchboard, I want to set a variable
(strAdmin) to "Y." When the switchboard opens the projects form, I want that
variable to "carry over" to the event code that runs on that other form.
I can't figure out how to do that. Using "Public" doesn't seem to carryy it
from one form to another.
If I can't "carry over" the variable, is there a way to "stuff" the "Y" into
an unbound text box in the projects form that is opened? Then I could
reference that text box in the form's code.
 
R

Roger Carlson

You can pass parameters to a form with the OpenArgs property. It's the last
value in the OpenForm parameter list.

On my website (www.rogersaccesslibrary.com), is a small Access database
sample called "OpenArgs.mdb" which illustrates how to do this. You can find
it here: http://www.rogersaccesslibrary.com/forum/forum_posts.asp?TID=307

--
--Roger Carlson
MS Access MVP
Access Database Samples: www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L
 

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