Enter parameter value for combobox filter (1 Viewer)

shafara7

Registered User.
Local time
Today, 16:12
Joined
May 8, 2017
Messages
118
Hi, I have been doing combox filter for a while now and it works fine except for this one Form named Messung.
The form has a subform named sfmMessung and I would like to filter the records according to locations, thus, I invented the combobox for the location named cboStandort.

Below is the vba codes that I use for the combobox:
Code:
Private Sub cboStandort_AfterUpdate()
    If IsNull(cboStandort.value) Then
        sfmMessung.Form.FilterOn = False
    Else
        sfmMessung.Form.FilterOn = True
        sfmMessung.Form.Filter = "indBemusterungsstelle  = " & cboStandort.value
    End If
End Sub

When I run the Form and clicked on the combobox, a window for Enter Parameter Value came out with the indBemusterungsstelle below it.
It confuses me because I have another form with the same combobox filter and it works ok. So I applied the same technique and codes to this Form but this parameter thing happen.

I have provided photos of the Query for the subform and combobox to make it clear.
But I appologize if it gives you headache because it's in german.
Can anybody tell me what's wrong with the parameter value?
 

Attachments

  • Query Form Messung.PNG
    Query Form Messung.PNG
    97.9 KB · Views: 173
  • Query Combobox Standort.PNG
    Query Combobox Standort.PNG
    15.6 KB · Views: 179

moke123

AWF VIP
Local time
Today, 11:12
Joined
Jan 11, 2013
Messages
3,852
try reversing
Code:
        sfmMessung.Form.FilterOn = True
        sfmMessung.Form.Filter = "indBemusterungsstelle  = " & cboStandort.value
to

Code:
        sfmMessung.Form.Filter = "indBemusterungsstelle  = " & cboStandort.value
        sfmMessung.Form.FilterOn = True
 

Orthodox Dave

Home Developer
Local time
Today, 15:12
Joined
Apr 13, 2017
Messages
218
I think Access is telling you that indBemusterungsstelle isn't in the form query results. In your image, there is no indBemusterungsstelle in the fields at the bottom of the screen. Try adding this field and see if it works then.

(Boy you don't half have long words in German!)
 

shafara7

Registered User.
Local time
Today, 16:12
Joined
May 8, 2017
Messages
118
Thank you for your reply.

moke123: I tried reversing the codes like you said but no improvement. The parameter window keep popping out.

Orthodox Dave: Yeah I figured that is the problem too. I want to add the table which consist the "indBemusterungsstelle" but it won't let me run the query because it says something about the SQL being too complex or too many links.
I guess it's because the table for the locations is not directly linked with the record in the subform.
 

Orthodox Dave

Home Developer
Local time
Today, 15:12
Joined
Apr 13, 2017
Messages
218
I notice from your combo box query image that tblBemusterungsstelle doesn't include the field indBemusterungsstelle.
 

shafara7

Registered User.
Local time
Today, 16:12
Joined
May 8, 2017
Messages
118
Because on the other form that I was working on, I did not include the table tblBemusterungsstelle but it still works.
I tried adding that table though, but it gets more complicated error.
Feeling like smashing my computer already.
 

Orthodox Dave

Home Developer
Local time
Today, 15:12
Joined
Apr 13, 2017
Messages
218
We all feel like that sometimes.

I am a little confused as to how it works on the other form but not this one. That other form's record source must include the field being filtered or there would be an error. It's worth having another careful look there, before smashing the computer.

If you still want to add the other table to the SQL query, there is another way to simplify it. If you save the form's sql as a saved query, you can then create a new sql form query with the saved query as one of the "tables" and the other table linking to it. This should get round the complexity problem.
 

shafara7

Registered User.
Local time
Today, 16:12
Joined
May 8, 2017
Messages
118
The solution lies at reply number #5. Silly me.
Thank you Orthodox Dave.
 

Users who are viewing this thread

Top Bottom