View Full Version : subform filter problem


fbt
06-30-2001, 10:32 AM
please take the time to read this, if i spend another couple hours trying to fix problem, i may be forced to drive my car into a brick wall.

i have a subform that has a query as a control source. i need this form to filter on the current event of another subform. seems pretty striaght forward. it actually worked twice but it only works sparatically.

heres the code for the current event of the other subform:

Private Sub Form_Current()
If [Form_eachjob].NewRecord Then
[Form_eachcomputer].AllowAdditions = False
Else
[Form_eachcomputer].AllowAdditions = True
'Stop
'___here is the code in question__________
[Form_eachcomputer].Filter = "[eachcomputer Query].jobNum=" & [Form_eachjob].[ID]
msgbox [Form_eachcomputer].Filter
[Form_eachcomputer].FilterOn = True
'________________________________________
End If
End Sub

you may be saying "geewiz that line:

"[eachcomputer Query].jobNum=" & [Form_eachjob].[ID]

should be:

"[Form_eachcomputer].jobNum=" & [Form_eachjob].[ID]"

but actually on the form_eachcomputer i right clicked the field "jobnum" and selected "filter by selection" and grabbed the filter generated by access from the properties of that form. point being, i know that filter works.

there are no error messages. if i actually look at the properties of the form when the filter is supposedly on, it shows no filter. then if i manually enter the filter it does work. you would think that for some reason the filter string isnt making it to the form but the msgbox does show the correct filter. i know the event is firing b/c of the msgbox too. wtf? ive tried saving and reopening the db and ive tried compact and repair...rebooting. im almost sure its a bug in access at this point...btw im using access xp.

[This message has been edited by fbt (edited 06-30-2001).]

charityg
07-02-2001, 01:34 PM
if you can't arrive at your solution with a filter, have you entertained resetting the datasource for form_eachcomputer. Such as

[Form_eachcomputer].datasource = "Select blah blah from this WHERE [eachcomputer Query].jobNum=" & [Form_eachjob].[ID] & ";"

[form_eachcomputer].requery


On second thought, have you tried
forms![Form_eachcomputer].Filter = "[eachcomputer Query].jobNum=" & forms![Form_eachjob].[ID]
msgbox forms![Form_eachcomputer].Filter
forms![Form_eachcomputer].FilterOn = True

Just a thought

HTH
Charity

fbt
07-03-2001, 03:01 PM
im actually using the same code i posted originally, but now i made the form a seperate window and it works. now i realize the problem is that the subforms arent communicating. i cant reference a control on a subform from another subform. i cant do something like:

subform1.text1 = subform2.text1

to get around that problem i made text box on the main form and used that to communicate between subforms.

mainform.text1 = subform1.text1
subform2.text1 = mainform.text1

changing the filter from subform to subform does the same thing.

i want to get it in the main form as a subform though so ill definatelty try using the ".datasource" tommorrow. that might work. as for the second idea, i already tried that.

thanks for the input dude.