Passing Parameters to a Form

KabirPatel

Registered User.
Local time
Today, 20:36
Joined
Nov 16, 2006
Messages
38
Hi all,

I have a continuous form that is bound to a SQL Server view.

For each record in my form I have a button, which when pressed opens up a second form. The second form is bound to a stored procedure that takes a parameter. The parameter value that I want to pass to this second form is the value of one of the fields in the first form.

I did the following in the click event of the button on my first form:

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "SecondForm"

stLinkCriteria = "[Field1]=" & "'" & Me![Field1] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

However, when I run this it keeps prompting me to specify the value of Field1 so this value is obviously not getting through. Do you have any idea why this might be happening?

Thanks in advance
Kabir
 
Yes Field1 is the name... any ideas?

Cheers,
Kabir
 
Your field and your form control appear to have the same name. This can cause problems (I know Access does this by default, so don't blame me).
 
Then, yes (as neileg mentioned) rename your text box to something else (like txtField1 - but I would suggest naming your fields and objects as meaningful names so that someone coming in after you, or even yourself years down the line, can easily see what they are).

Also, get rid of the BANG operator as you are referring to the recordset object when using it and in this case you are concerned with the textbox value instead.

Code:
stLinkCriteria = "[Field1]=" & "'" & Me.txtField1 & "'"
 

Users who are viewing this thread

Back
Top Bottom