Open form based on combo box selection

C

cathywoodford

Hi. I am creating a very simple db. It has a movie table, customer
table and rental table. I have a search form created with a combo box
of movie titles. I want the user to select a movie title and it will
bring up a form that tells them who the movie is rented too if it's
rented. I have the form opening but not to the user selection. Here
is the code I have:

Private Sub cmbSearch_AfterUpdate()
Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmMovies"
stLinkCriteria = Me!cmbSearch.Value
DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormReadOnly
DoCmd.Maximize
End Sub

Hope someone can help.
 
O

Ofer Cohen

In the criteia you need to specify the field name in the table, that you want
to filter on

Yours
stLinkCriteria = Me!cmbSearch.Value

Should be if the field is number type
stLinkCriteria = "[FieldNameInTable] = " & Me!cmbSearch

Should be if the field is text type
stLinkCriteria = "[FieldNameInTable] = '" & Me!cmbSearch & "'"
 
C

cathywoodford

Hi. Thanks for the reply. I tried this but the form still opens with
the first record. On the navigation buttons it specifies that it is
filtered but it doesn't. Is there something that I could be missing in
the properties of either the form or combo box.?

Thanks.
CW

Ofer said:
In the criteia you need to specify the field name in the table, that you want
to filter on

Yours
stLinkCriteria = Me!cmbSearch.Value

Should be if the field is number type
stLinkCriteria = "[FieldNameInTable] = " & Me!cmbSearch

Should be if the field is text type
stLinkCriteria = "[FieldNameInTable] = '" & Me!cmbSearch & "'"

--
Good Luck
BS"D


Hi. I am creating a very simple db. It has a movie table, customer
table and rental table. I have a search form created with a combo box
of movie titles. I want the user to select a movie title and it will
bring up a form that tells them who the movie is rented too if it's
rented. I have the form opening but not to the user selection. Here
is the code I have:

Private Sub cmbSearch_AfterUpdate()
Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmMovies"
stLinkCriteria = Me!cmbSearch.Value
DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormReadOnly
DoCmd.Maximize
End Sub

Hope someone can help.
 

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