Filter problem on Form Open

K

kit

Our database guru left and now I'm modifying his old database code for a new
database. In the old code a filter was used to open a form

DoCmd.OpenForm FormName, , ,"[Spacecraft] = '"& Me![Abbreviation]&"'" , , ,
ArgPassed

This worked for the old forms. It would open the form with the data for the
given spacecraft or if there was no data a new empty form would be opened.
This same command is not working for the new forms. With the new forms the
first criteria gets loaded into the server filter property and when you
change spacecraft you still get the first criteria. The old forms didn't
have a server filter property. I've been reading lots of threads on this
site and have tried several fixes from other's advise first I added

Me.Filter = ""
Me.Filter = False

to the Form_Open event to no avail. Then I took the filter criterias out of
the
DoCmd.OpenForm FormName, , , , , , ArgPassed - command

and instead included the following in the Form_Open event

Set SpaceCraftRecords = New ADODB.Recordset
LinkCriteria = "SELECT * FROM dbo.dqtLinkRadioRx WHERE [Spacecraft] = '"
& Me.OpenArgs & "'"
SpaceCraftRecords.Open LinkCriteria, CurrentProject.connection,
adOpenKeyset, adLockOptimistic
Set Me.Recordset = SpaceCraftRecords

This works for spacecraft that already have data and changes to the correct
data when you change spacecraft. But instead of getting a new empty form for
a spaceraft that has no link data you get a totally blank form. Two things
I've observed in my futile attempts to debug this 1) the old form open
function recognized that you where opening a new record, Me.NewRecord = -1
the new form doesn't, Me.NewRecord = 0 and 2) when it gets to

Me.OrderBy = "dqtLinkRadioRx.Name"

you get taken to Form_Activate and Form_Current events when it works
correctly. But when you try to open a new empty form it just skips right
over OrderBy and goes to the command on the next line without going to
Form_Activate and Form_Current.

Help to understand and solve this problem would be greatly appreciated.
I've been spinning my wheels on this for a couple of days.

Kit
 
Top