Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form Filter working only on second and subsequent selection

Status
Not open for further replies.

WattoAtBerneray

IS-IT--Management
Sep 4, 2009
5
AU
MS Access XP.....

I have made a large calendar of events:
For each day, four or five events are summarised.
I have a 'Show Details' command button to show the details next to each of these events operating via a new form.
I pass the event number via: (where, say, event =1)

stLinkCriteria = "((([EventID])=" & Me![EventID] & "))"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Checking the target form I get a blank form with a filter of, say, FILTER....... ((([EventID])=1)) [Where the Event id = 1] Filter Correct but no record selected!!!!!!
now if I click another event button or even the same event button on the parent form without closing the detail form - it works perfectly finding and displaying the correct event.
I only have problems on the initial displaying of the form.
Spent the entire day on the problem with no result...
Any help with be greatefully received.
 
Hi watto,

Just a guess, but have you tried:
[tt]
DoCmd.OpenForm stDocName, , , stLinkCriteria
Forms!stDocName.Requery
[/tt]

ATB

Darrylle

Never argue with an idiot, he'll bring you down to his level - then beat you with experience.
 
I regret to tell you - No cigars!

I tried this in the code as you have suggested.
I even added this code to the Open control of the called form.

No luck.

[what is worse is that it did work momentarily a couple of days ago...... with no apparent difference in the opjects]
 
Watto,

Any code in the form 'On Open / Load' events?


ATB

Darrylle

Never argue with an idiot, he'll bring you down to his level - then beat you with experience.
 
Darryl,

Thank you for taking the time to comment. Much appreciated.
Am trying to re-do the bookings system for our Tall Ship.
.....
I take it that your comments refer to the called form i.e 'B'

in the:
Allow Filters.. Yes
On Open.. [blank]
On Load.. [blank]
Cycle.... Current Record
On Activate.. [blank]
On Got Focus [blank]

Nothing that I'm aware of should be activating on initial load
 
I am referring to thread702-1567895, no idea of form names in this thread.

One other event: <On current> - anything there?

ATB

Darrylle

Never argue with an idiot, he'll bring you down to his level - then beat you with experience.
 
Darrylle,

Sorry, missed that one, but the 'On Current'... is blank as well.
 
Watto,

If you haven't sussed this yet, then bear with me and try this:

1)
Use a constant instead of the stLinkCriteria variable:
DoCmd.OpenForm stDocName, , , "EventID = 2"

Where 2 is an existing EventID (but not 1).

This should also fail, but DO NOT touch the child form.
Select "Show Details" on the master form again.
You say that this should now work, but, does the record in the child form have an event ID of 2?

2) Are there any sub forms on either the master or child forms?

ATB

Darrylle



Never argue with an idiot, he'll bring you down to his level - then beat you with experience.
 
Darrylle,

Definately not sussed. [But I am thinking of going through all the code again to find any reference to EventID on any form.]

Following your instructions:
Set the 'hard coded' value for Event Id = 2 [no problems with this being a genuine event they currently go from 1 to about 1800 in the table]

Selected the screen via the normal path. i.e.

Form 'Calendar'
---SubForm 'Dates_Subform' [There are 28,29,30, or 31
of these subforms on the Calendar form depending
on month]
----Linked form 'DateDetail' - No subforms
----Linked form 'SeaTimeForm' - Two Subforms

It is this link between DateDetail and SeatimeForm that Sets the EventId. The previous links are by Date.

Initial selection: Blank form displays.
Check of filter shows EventID = 2

Reselect of any of the 'Show Event' command buttons on the DateDetail form: Filter shows EventID = 2
Event 2 details are displayed correctly.

As you can see 'Path' above there are quite a number of forms and subforms open.

However, There are no subforms on the parent form DateDetail
There are two subforms on the SeaTimeForm

Code on parent form DateDetail is:..................................
Option Compare Database

Private Sub GetEvent_Click()
On Error GoTo Err_GetEvent_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "SeatimeForm"

stLinkCriteria = "((([EventID])=" & Me![EventID] & "))"
DoCmd.OpenForm stDocName, , , stLinkCriteria
'DoCmd.OpenForm stDocName, , , "EventId = 2" '<--------- Test of literal


Exit_GetEvent_Click:
Exit Sub

Err_GetEvent_Click:
MsgBox Err.Description
Resume Exit_GetEvent_Click

End Sub
Private Sub NewEvent_Click()
On Error GoTo Err_NewEvent_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "SeatimeForm"
'DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormAdd, acDialog
DoCmd.OpenForm stDocName, , , , acFormAdd, acDialog
'DoCmd.GoToRecord , , acNewRec

Exit_NewEvent_Click:
Exit Sub

Err_NewEvent_Click:
MsgBox Err.Description
Resume Exit_NewEvent_Click

End Sub
Private Sub ExitDatesDetail_Click()
On Error GoTo Err_ExitDatesDetail_Click


DoCmd.Close

Exit_ExitDatesDetail_Click:
Exit Sub

Err_ExitDatesDetail_Click:
MsgBox Err.Description
Resume Exit_ExitDatesDetail_Click

End Sub
.............................................

Both Subforms on the SeaTimeForm are linked by EventID
I havn't looked at these in detail yet.

[Did I tell you that I inherited the DB in all it's bloody awful glory?????]

Ta Ian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top