Open Form button saves info in forms filter field

S

Steve Roberts

I created a button to open a form [CompanyJournal] based on the current
form's ID1 field. I used the Access wizard to do this. The problem is, after
a series of clicks the form that I am opening saves the ID1= information in
the forms filter so every time I click after that I only get that info no
matter what the parents ID1 is. I can duplicate it on every form open
button I create if I click often enough.

Is there something I need to change on the form properties to stop this?

Here is the code the wizard created.

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "CompanyJournal"

stLinkCriteria = "[CompanyID]=" & Me.[ID1]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Thanks for your suggestions.

Steve
 
M

Marshall Barton

Steve said:
I created a button to open a form [CompanyJournal] based on the current
form's ID1 field. I used the Access wizard to do this. The problem is, after
a series of clicks the form that I am opening saves the ID1= information in
the forms filter so every time I click after that I only get that info no
matter what the parents ID1 is. I can duplicate it on every form open
button I create if I click often enough.

Is there something I need to change on the form properties to stop this?

Here is the code the wizard created.

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "CompanyJournal"

stLinkCriteria = "[CompanyID]=" & Me.[ID1]
DoCmd.OpenForm stDocName, , , stLinkCriteria


The WhereCondition filter string is placed in the form's
Filter. Sometimes it does get saved when you close the
form, but that shouldn't matter as long as you reopen the
form using a similar procedure.

OTOH, if the form was already open when you click the
button, the WhereCondition argument is ignored and the
behavior you're seeing is normal.
 

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

Similar Threads


Top