Connecting two forms with one field in Access when you click a button.

J

JJ

I am trying to open a second form from a the first one
when I click on a button and the second form is supposed
to show the information for the field Application Name
which needs to be pulled from the first form.

I have tried using:

Private Sub cmdInterfaceList_Click()

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmApplicationInterface"
stLinkCriteria = "[Application Name]"
DoCmd.OpenForm stDocName, , , stLinkCriteria

End Sub

This opens the second form, but the Application Name that
it uses does not match the one showing in the first form.

I have also tried using:

Private Sub cmdInterfaceList_Click()

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmApplicationInterface"
stLinkCriteria = "[Application Name]= Me![Application
Name]"

DoCmd.OpenForm stDocName, , , stLinkCriteria

This opens a small window that asks you to enter the
Parameter Value for Me!Application Name.

What can I change to make the second window open with the
correct Application Name without having to type it into a
parameter window?

Thanks!
 
J

John Vinson

I am trying to open a second form from a the first one
when I click on a button and the second form is supposed
to show the information for the field Application Name
which needs to be pulled from the first form.
Private Sub cmdInterfaceList_Click()

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmApplicationInterface"
stLinkCriteria = "[Application Name]= Me![Application
Name]"

DoCmd.OpenForm stDocName, , , stLinkCriteria

This opens a small window that asks you to enter the
Parameter Value for Me!Application Name.

What can I change to make the second window open with the
correct Application Name without having to type it into a
parameter window?

This is closer - but you're passing it the literal text string
Me![Application Name] rather than the *value* within that control.

Try

stLinkCriteria = "[Application Name]= '" & Me![Application Name] & "'"

assuming that ApplicationName is a Text field, therefore needing
delimiters ' around it.


John W. Vinson[MVP]
 
J

JJ

Thank you John, that allowed the second form to come up
without the small parameter window, but now the value
that is in Application Name, isn't the value pulled into
the second form. It actually lists the first value in
the table for the Application Name. In the first form,
Application Name is a drop down list, could this be why
the value is not being transferred? If so, is there a
way to set it so that the value that is picked from the
drop down list is what is transferred?

Thanks agagin for your help!
-----Original Message-----
I am trying to open a second form from a the first one
when I click on a button and the second form is supposed
to show the information for the field Application Name
which needs to be pulled from the first form.
Private Sub cmdInterfaceList_Click()

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmApplicationInterface"
stLinkCriteria = "[Application Name]= Me! [Application
Name]"

DoCmd.OpenForm stDocName, , , stLinkCriteria

This opens a small window that asks you to enter the
Parameter Value for Me!Application Name.

What can I change to make the second window open with the
correct Application Name without having to type it into a
parameter window?

This is closer - but you're passing it the literal text string
Me![Application Name] rather than the *value* within that control.

Try

stLinkCriteria = "[Application Name]= '" & Me! [Application Name] & "'"

assuming that ApplicationName is a Text field, therefore needing
delimiters ' around it.


John W. Vinson[MVP]
.
 
J

John Vinson

Thank you John, that allowed the second form to come up
without the small parameter window, but now the value
that is in Application Name, isn't the value pulled into
the second form. It actually lists the first value in
the table for the Application Name. In the first form,
Application Name is a drop down list, could this be why
the value is not being transferred? If so, is there a
way to set it so that the value that is picked from the
drop down list is what is transferred?

I have no idea how your tables are structured, so I'm not at all sure
what field should be passed. Remember: a combo box ("dropdown") is NOT
data; it's a display tool. The value stored in the table is NOT
necexsarily the same as the value that you see; in fact it usually
isn't!

If you pass the value of the combo box in your code, what will be
passed is the bound column - which may well be an invisible numeric
ID. On the second form, you should also have an invisible numeric ID
and it's that field which should be set.

John W. Vinson[MVP]
 

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