Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
tobiasaechter
Contributor III
Contributor III

Field triggers for specific sheet only

Hi,

is it possible to set a field trigger only on a specific sheet?

What I want to achieve is to have a field (Field 1) which is used in two different sheets.

In sheet A, Field 1 should be cleared when Field 2 is selected. In sheet B, Field 1 should stay selected when Field 2 is selected.

Is this possible in Qlikview?

Thanks.

1 Solution

Accepted Solutions
chrismarlow
Specialist II
Specialist II

Hi,

I am not sure I understand what you are saying. If I add the following (and ad triggers as appropriate) it seems to work (I think …);

Public Sub ConditionalClear1()

	if ActiveDocument.ActiveSheet.GetProperties.Name="SheetA" then
	
		ActiveDocument.Fields("Field1").Clear

	end if
	
End Sub

Public Sub ConditionalClear2()

	if ActiveDocument.ActiveSheet.GetProperties.Name="SheetA" then
	
		ActiveDocument.Fields("Field2").Clear
		
	end if
	
End Sub

QVW attached again, let me know if it helps or I am missing something.

Cheers,

Chris.

 

 

View solution in original post

5 Replies
chrismarlow
Specialist II
Specialist II

Hi,

You can use a macro attached to trigger action on the field that clears the field (or not) depending on the sheet;

Public Sub ConditionalClear()

	if ActiveDocument.ActiveSheet.GetProperties.Name="SheetA" then
	
		ActiveDocument.Fields("Field1").Clear
		
	end if
	
End Sub
 

20190209_2.png

Attaching my QVW, although personal edition so you may not be able to open.

You probably want to test this approach a lot, as the macros can be flaky/environment dependent.

Cheers,

Chris.

 

tobiasaechter
Contributor III
Contributor III
Author

Hi,

thanks for the hint. That seems like it could be a solution.

Nevertheless though I would need two Macros then as I would need "Field1" to be cleared when "Field2" is selected but also "Field2" to be cleared when "Field1" is selected.

So I would need to put a Macro on both fields in order to each clear the other one if selected.

But that doesn't seem to work. Somehow I can always only create one Macro and if I try to use a different one on the other field  the script of both macros will always automatically stay the same.

Am I missing something here?

 

chrismarlow
Specialist II
Specialist II

Hi,

I am not sure I understand what you are saying. If I add the following (and ad triggers as appropriate) it seems to work (I think …);

Public Sub ConditionalClear1()

	if ActiveDocument.ActiveSheet.GetProperties.Name="SheetA" then
	
		ActiveDocument.Fields("Field1").Clear

	end if
	
End Sub

Public Sub ConditionalClear2()

	if ActiveDocument.ActiveSheet.GetProperties.Name="SheetA" then
	
		ActiveDocument.Fields("Field2").Clear
		
	end if
	
End Sub

QVW attached again, let me know if it helps or I am missing something.

Cheers,

Chris.

 

 

tobiasaechter
Contributor III
Contributor III
Author

Thanks Chris,

it's working now.
I never used macros before so I didn't understand that I can write two substatements under each other.
chrismarlow
Specialist II
Specialist II

Glad it is working. I don't find it the most intuitive thing to work with.