Parm reference in called subroutine

S

Steve S

The code below opens the correct form, the msgbox shows the correct string
(Order Tee Shirts), but I get an error msg on the next line that :

Microsoft Access can’t find the form ‘strToForm' referred to….

How do I get the value for the string to be substituted correctly into the
assignment statement?


Call OpenNewForm("Order Tee Shirts", "Team Entries")
…
…
Public Sub OpenNewForm(strToForm As String, strFromForm As String)

DoCmd.OpenForm strToForm
MsgBox (strToForm)
[Forms]![strToForm]![Full Name] = [Forms]![Team Entries]![Full Name]

End Sub
 
R

Rick Brandt

Steve said:
The code below opens the correct form, the msgbox shows the correct
string (Order Tee Shirts), but I get an error msg on the next line
that :

Microsoft Access can't find the form 'strToForm' referred to..

How do I get the value for the string to be substituted correctly
into the assignment statement?


Call OpenNewForm("Order Tee Shirts", "Team Entries")
.
.
Public Sub OpenNewForm(strToForm As String, strFromForm As String)

DoCmd.OpenForm strToForm
MsgBox (strToForm)
[Forms]![strToForm]![Full Name] = [Forms]![Team Entries]![Full
Name]

End Sub

Instead of the syntax...

[Forms]![strToForm]![Full Name]

....use...

Forms(strToForm)![Full Name]
 
S

Steve S

thanks. That worked but I sure do not know why. I had tried several
versions trying to make it work with & and " with no success. I would never
have tried what you suggested. Can you explain what adn why?

thanks again

steve

Rick Brandt said:
Steve said:
The code below opens the correct form, the msgbox shows the correct
string (Order Tee Shirts), but I get an error msg on the next line
that :

Microsoft Access can't find the form 'strToForm' referred to..

How do I get the value for the string to be substituted correctly
into the assignment statement?


Call OpenNewForm("Order Tee Shirts", "Team Entries")
.
.
Public Sub OpenNewForm(strToForm As String, strFromForm As String)

DoCmd.OpenForm strToForm
MsgBox (strToForm)
[Forms]![strToForm]![Full Name] = [Forms]![Team Entries]![Full
Name]

End Sub

Instead of the syntax...

[Forms]![strToForm]![Full Name]

....use...

Forms(strToForm)![Full Name]
 
Top