Making use of a Passed Argument

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

HI

I am trying to pass an argument from one form to another (from a service
mainform to a staff data entry form). The argument is called "serviceN",
which takes its value from a combo box on a mainform frmServices. I want to
pass ServiceN to a popup form FrmStaff_Entry.

I am using the following code activated by a button on the mainform:

Private Sub Namex_DblClick(Cancel As Integer)

DoCmd.OpenForm "frmStaff_Entry", , , "Name = " & Chr(34) & Me.Namex &
Chr(34), , , "ServiceN"

End Sub


Ok. so this uses openargs to pass the argument ServiceN over to the
frmService_Entry as it opens.... so far so good

what I need is to now have the value carried by the ServiceN argument
display on the frmServiceEntry. I wrote this little sub on frmStaff_Entry to
see where i am up to at this point:

Private Sub Command28_Click()
MsgBox OpenArgs
End Sub

....and it displays the NAME of the argument (ServiceN), and not the value it
holds (ie a sevice name from the combo on the original form).

How do i 'translate' a passed argument back into the viewable value it
contains? Ultimately this passed value informs access which service the staff
member is attatched to....

I have followed various previously posted answers to similar questions to
mine, but to no avail.

thanks
 
If ServiceN is a field or variable, then list it without the quotes:

DoCmd.OpenForm "frmStaff_Entry", , , "Name = " & Chr(34) & Me.Namex &
Chr(34), , , ServiceN

Right now, you are passing it the literal string "ServiceN". Without the
quotes, it will pass the value of the variable.

--
--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
 
Roger said:
If ServiceN is a field or variable, then list it without the quotes:

DoCmd.OpenForm "frmStaff_Entry", , , "Name = " & Chr(34) & Me.Namex &
Chr(34), , , ServiceN

Right now, you are passing it the literal string "ServiceN". Without the
quotes, it will pass the value of the variable.

Just as a followup, 'Name' is a reserved word in Access. You shouldn't
name (no pun intended) any of your fields or any other object with a
reserved word. Sometimes it'll work, sometimes it won't. It really
depends on what the code is trying to do.

That's probably not the problem here, but you should make the correction
for the future anyway.

Here's a list of all the reserved words:
http://support.microsoft.com/kb/q286335/
 
In addition to the valuable info you have already received, the recommended
location to use the OpenArgs received is in the Load event of the receiving
form. so to put it in to the control:

Me.SomeControl = Me.OpenArgs
 

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

Back
Top