help with access 2007 , may be filter problem

M

mhmaid

have just started using access 2007 , therefore I am facing many problems

i have a button on my main form when clicked it will open a search
form,there when i double click a record it will take me to the same record in
main form (filter)

after that i may need to search for another record , so i will click the
button , open the search form and from there it will open the main form
filtered on the record selected in the search form

this was going ok in access 2003
but in access 2007 , it will take me to the record that was selected in the
first time ,i.e.first time filtered

how can i solve this problem
i wanted to put the code behind the search form but unfortunately I am at
home now and dont have db with me , it at office
but its just an amenede copy of this code

Private Sub ReviewProducts_Click()
' This code created in part by Command Button Wizard.
On Error GoTo Err_ReviewProducts_Click

Dim strMsg As String, strTitle As String
Dim intStyle As Integer
Dim strDocName As String, strLinkCriteria As String

' If CompanyName control is blank, display a message.
If IsNull(Me![CompanyName]) Then
strMsg = "Move to the supplier record whose products you want to
see, then press the Review Products button again."
intStyle = vbOKOnly
strTitle = "Select a Supplier"
MsgBox strMsg, intStyle, strTitle
Me![CompanyName].SetFocus
Else
' Otherwise, open Product List form, showing products for current
supplier.
strDocName = "Product List"
strLinkCriteria = "[SupplierID] = Forms![Suppliers]![SupplierID]"
DoCmd.OpenForm strDocName, , , strLinkCriteria
DoCmd.MoveSize (1440 * 0.78), (1440 * 1.8)
End If

Exit_ReviewProducts_Click:
Exit Sub

Err_ReviewProducts_Click:
MsgBox Err.Description
Resume Exit_ReviewProducts_Click

End Sub

let is say my main form is product list
and first i seach for record number 49
then i wanted to see record number 584
form will open but will show me record number 49

this is only with access 2007
before every thing was going fine
 
D

Danny J. Lesandrini

If I understood your issue correctly, you have two choices:

1) Programmatically change the filter on the open form and requery.
2) Close the form before reopening it.

I always choose option 2 because I'm lazy. All it takes is one additional
line of code. Put a call to close the form right before a call to open it.

DoCmd.Close acForm strDocName
DoCmd.OpenForm strDocName, , , strLinkCriteria

--
Danny J. Lesandrini
(e-mail address removed)
www.amazecreations.com


mhmaid said:
have just started using access 2007 , therefore I am facing many problems

i have a button on my main form when clicked it will open a search
form,there when i double click a record it will take me to the same record in
main form (filter)

after that i may need to search for another record , so i will click the
button , open the search form and from there it will open the main form
filtered on the record selected in the search form

this was going ok in access 2003
but in access 2007 , it will take me to the record that was selected in the
first time ,i.e.first time filtered

how can i solve this problem
i wanted to put the code behind the search form but unfortunately I am at
home now and dont have db with me , it at office
but its just an amenede copy of this code

Private Sub ReviewProducts_Click()
' This code created in part by Command Button Wizard.
On Error GoTo Err_ReviewProducts_Click

Dim strMsg As String, strTitle As String
Dim intStyle As Integer
Dim strDocName As String, strLinkCriteria As String

' If CompanyName control is blank, display a message.
If IsNull(Me![CompanyName]) Then
strMsg = "Move to the supplier record whose products you want to
see, then press the Review Products button again."
intStyle = vbOKOnly
strTitle = "Select a Supplier"
MsgBox strMsg, intStyle, strTitle
Me![CompanyName].SetFocus
Else
' Otherwise, open Product List form, showing products for current
supplier.
strDocName = "Product List"
strLinkCriteria = "[SupplierID] = Forms![Suppliers]![SupplierID]"
DoCmd.OpenForm strDocName, , , strLinkCriteria
DoCmd.MoveSize (1440 * 0.78), (1440 * 1.8)
End If

Exit_ReviewProducts_Click:
Exit Sub

Err_ReviewProducts_Click:
MsgBox Err.Description
Resume Exit_ReviewProducts_Click

End Sub

let is say my main form is product list
and first i seach for record number 49
then i wanted to see record number 584
form will open but will show me record number 49

this is only with access 2007
before every thing was going fine
 
M

mhmaid

thank your for your quik response
I will try that
thanks


Danny J. Lesandrini said:
If I understood your issue correctly, you have two choices:

1) Programmatically change the filter on the open form and requery.
2) Close the form before reopening it.

I always choose option 2 because I'm lazy. All it takes is one additional
line of code. Put a call to close the form right before a call to open it.

DoCmd.Close acForm strDocName
DoCmd.OpenForm strDocName, , , strLinkCriteria

--
Danny J. Lesandrini
(e-mail address removed)
www.amazecreations.com


mhmaid said:
have just started using access 2007 , therefore I am facing many problems

i have a button on my main form when clicked it will open a search
form,there when i double click a record it will take me to the same record in
main form (filter)

after that i may need to search for another record , so i will click the
button , open the search form and from there it will open the main form
filtered on the record selected in the search form

this was going ok in access 2003
but in access 2007 , it will take me to the record that was selected in the
first time ,i.e.first time filtered

how can i solve this problem
i wanted to put the code behind the search form but unfortunately I am at
home now and dont have db with me , it at office
but its just an amenede copy of this code

Private Sub ReviewProducts_Click()
' This code created in part by Command Button Wizard.
On Error GoTo Err_ReviewProducts_Click

Dim strMsg As String, strTitle As String
Dim intStyle As Integer
Dim strDocName As String, strLinkCriteria As String

' If CompanyName control is blank, display a message.
If IsNull(Me![CompanyName]) Then
strMsg = "Move to the supplier record whose products you want to
see, then press the Review Products button again."
intStyle = vbOKOnly
strTitle = "Select a Supplier"
MsgBox strMsg, intStyle, strTitle
Me![CompanyName].SetFocus
Else
' Otherwise, open Product List form, showing products for current
supplier.
strDocName = "Product List"
strLinkCriteria = "[SupplierID] = Forms![Suppliers]![SupplierID]"
DoCmd.OpenForm strDocName, , , strLinkCriteria
DoCmd.MoveSize (1440 * 0.78), (1440 * 1.8)
End If

Exit_ReviewProducts_Click:
Exit Sub

Err_ReviewProducts_Click:
MsgBox Err.Description
Resume Exit_ReviewProducts_Click

End Sub

let is say my main form is product list
and first i seach for record number 49
then i wanted to see record number 584
form will open but will show me record number 49

this is only with access 2007
before every thing was going fine
 

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