Navigation Form - Where Clause Syntax (1 Viewer)

jack555

Member
Local time
Today, 20:30
Joined
Apr 20, 2020
Messages
93
Instead of creating duplicate forms and queries, we could use the "Navigation Where Clause" in the navigation form. I used this successfully when the filter parameter is always fixed. However, could not able to pass through the textbox value in the main form to the syntax successfully. Below syntaxes, I tried in many ways with or without quotes, but not working.

[department]= Me!txtDept

Me!textDept is in the main navigation form
[department] is in the target form.

I want to use this approach since the same form used in different places with a different filter, hence I cannot add a condition in the "on load" event of the target form. Please help.

1606363800879.png


1606364005905.png


1606364284548.png
 
Last edited:

theDBguy

I’m here to help
Staff member
Local time
Today, 09:30
Joined
Oct 29, 2018
Messages
21,449
Hi. It's probably not working because Me only works in VBA. For form controls and properties, try taking it out. Or, use the full Forms! syntax.
 

jack555

Member
Local time
Today, 20:30
Joined
Apr 20, 2020
Messages
93
Hi. It's probably not working because Me only works in VBA. For form controls and properties, try taking it out. Or, use the full Forms! syntax.

Tried the below without success. Anything am I missing below?

1606364240088.png
 

jack555

Member
Local time
Today, 20:30
Joined
Apr 20, 2020
Messages
93
Can't do any testing right now, but try adding an equal sign at the beginning.

As is, are you getting a prompt?
I tried adding = sign, but now no records returned; earlier without =, all records were returned. I will wait for your availablility.

Thank you very much for your time and kind replies.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 09:30
Joined
Oct 29, 2018
Messages
21,449
I tried adding = sign, but now no records returned; earlier without =, all records were returned. I will wait for your availablility.

Thank you very much for your time and kind replies.
Sorry, going to bed now. See you tomorrow.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 00:30
Joined
May 7, 2009
Messages
19,231
you could just add code to the Form's Open event:
Code:
Private Sub Form_Open(Cancel As Integer)
On Error Goto Err_Handler
If Me.Parent.Name = "frmWelcomeManager" Then
        Me.Filter = "Department='" & Me.Parent.Form!txtDept & "'"
        Me.FilterOn = True
End If
Err_Handler:
End Sub


EDIT: if it is used as standalone form, or is used in another form (as subform),
it is best to just make a copy of this form and use the copy in your navigation form.
therefore, whatever modification you made on the form is only made to it's copy.
 

Users who are viewing this thread

Top Bottom