Polute value from one combi to next form combi

Magnus1982

Registered User.
Local time
Yesterday, 17:26
Joined
Apr 29, 2017
Messages
41
Hello.
I am looking for help.
At the moment i have form with combo box (cb1). This cb1 is linked to the tabele (Tb1/Column1) if i set up number in cb1 rest of field is field automatically (base on table). What i want to do is - I setting some number in cb1 and after i am pressing button (bn1) i wanna open new form with combi (cb2). cb2 is taking value from tb2/column1 (numbers in Tb1/column1 and Tb2colum2 are the same) and i want to have filtered value in cb2 (showing only numbers from cb1)

I already try do dcm.open and is not working. Do anybody can support me .
Sry for English

Regards
 
it will look as if it is a Cascading combo,
but it's not. Since we are only getting
subset of same column.

the #2 post will work only if there is really
a selection on cb1 on form1. but will only show
one item selected.

unfortunately you cannot select but 1 item in combo.
if you need to select multiple items you will need
a Listbox there.

you can disable the bn1 while there is no selection
yet and enable it when there is an item selected.
or you can check it to the second form.

on the second form:
Code:
Private Sub Form_Load()
If Forms!Form1.cb1.ListIndex = -1
	'there is no selection at cb1
	'what do you want to do.
	' in my case, show all records
	me.cb2.RowSource="Select Column2 From Tb2;"
Else
	me.cb2.RowSource="Select Column2 From Tb2 Where Column2=" & _
	Forms!Form1.cb1
End if
End Sub

if you elect to use listbox, so you can extend more
selection, on Form2 Load event:

Code:
Private Sub Form_Load()
Dim var As Variant
Dim sNums as String
If Forms!Form1.lst1.ListIndex = -1
	Me.lst2.RowSource = "Select Column2 From Tb2;"
Else
	For Each var In Forms!Form1.lst1.ItemsSelected
		sNums = sNums & Forms!Form1.lst1.ItemData(var) & ","
	Next
	If sNums<> "" then sNums = Left(sNums,Len(sNums)-1)
	Me.lst2.RowSource="Select Column2 From Tb2 Where " & _
		"Column2 In (" & sNum & ");"
End If
End Sub
 

Users who are viewing this thread

Back
Top Bottom