Hi, I can't quite work out why something isnt working, so I just wondered if you guys could help me out.
I have a form displaying a record. Nothing strange there. The record is selected from the database and displayed in the form using a filter applied to the form, ie
criteria = "System=" & "'" & ...
DoCmd.OpenForm "browse_item"
Forms!browse_item.Filter = criteria
Forms!browse_item.FilterOn = True
I've been asked to put next and previous buttons on this form, and I can think of a fairly simple way to do it: remove the filter, build new criteria based on elements on the existing form, re-filter. It's not working though,. This is my code,
----------
Dim rR1, rR2, rR3, max As Integer
Dim criteria As String
rR1 = Forms!browse_item![RefR1]
rR2 = Forms!browse_item![RefR2]
rR3 = Forms!browse_item![RefR3]
max = DMax("[R3]", "Query1", "[R1] = " & rR1 & " AND [R2] = " & rR2)
R3 = R3 + 1
If R3 <= max Then
criteria = "R1=" & R1 & " AND " & "R2=" & R2 & " AND R3=" & R3
Else
R2 = R2 + 1
R3 = 0
criteria = "R1=" & R1 & " AND " & "R2=" & R2 & " AND R3=" & R3
End If
Forms!browse_item.FilterOn = False
Forms!browse_item.Filter = criteria
Forms!browse_item.FilterOn = True
------------------
It's attached to onclick of a button. When I click on the next button, the id fields (R1, R2 and R3) increment on screen but the other fields don't. Do I need to requry or something? There are about 100 fields on the sceen so putting in *.requery() for each one isn't really an option. Is there a 'requery all' or something? Or is requery not my problem?
Any help would be greatly appreciated, thanks in advance.
Jordan
I have a form displaying a record. Nothing strange there. The record is selected from the database and displayed in the form using a filter applied to the form, ie
criteria = "System=" & "'" & ...
DoCmd.OpenForm "browse_item"
Forms!browse_item.Filter = criteria
Forms!browse_item.FilterOn = True
I've been asked to put next and previous buttons on this form, and I can think of a fairly simple way to do it: remove the filter, build new criteria based on elements on the existing form, re-filter. It's not working though,. This is my code,
----------
Dim rR1, rR2, rR3, max As Integer
Dim criteria As String
rR1 = Forms!browse_item![RefR1]
rR2 = Forms!browse_item![RefR2]
rR3 = Forms!browse_item![RefR3]
max = DMax("[R3]", "Query1", "[R1] = " & rR1 & " AND [R2] = " & rR2)
R3 = R3 + 1
If R3 <= max Then
criteria = "R1=" & R1 & " AND " & "R2=" & R2 & " AND R3=" & R3
Else
R2 = R2 + 1
R3 = 0
criteria = "R1=" & R1 & " AND " & "R2=" & R2 & " AND R3=" & R3
End If
Forms!browse_item.FilterOn = False
Forms!browse_item.Filter = criteria
Forms!browse_item.FilterOn = True
------------------
It's attached to onclick of a button. When I click on the next button, the id fields (R1, R2 and R3) increment on screen but the other fields don't. Do I need to requry or something? There are about 100 fields on the sceen so putting in *.requery() for each one isn't really an option. Is there a 'requery all' or something? Or is requery not my problem?
Any help would be greatly appreciated, thanks in advance.
Jordan