M
Mikael Lindqvist
Hi everyone,
In first field I want to enter customber_number and then I'd like to to have
a list of all available invoices that belongs to that customer in the other
(multibox field).
Customer number is in one table (custTbl, CustID) and invoices in a second
table (invTbl, invNo).
Each table is related by the custID key.
Now, I have really tried to use this advice (from:
http://www.mvps.org/access/forms/frm0028.htm ):
Let's say you have two comboboxes, cbxCombo1 and cbxCombo2. The
RowSourceType of cbxCombo1 is set to "Field List" and RowSource to a table
Category. cbxCombo2 doesn't have anything under RowSource.
In this case, you can put code in the AfterUpdate event of cbxCombo1
that assigns the proper RowSource to cbxCombo2.
'**************** Code Start *************
Private Sub cbxCombo1_AfterUpdate()
Dim strSQL As String
strSQL = "Select " & Me!cbxCombo1
strSQL = strSQL & " from Categories"
Me!cbxCombo2.RowSourceType = "Table/Query"
Me!cbxCombo2.RowSource = strSQL
End Sub
'**************** Code End *************
But I can't get it to work.
1. What does "from Categories" in the SQL reference to? What would that
translate to in my case, invTble maybe?
2. Should cbxCombo1 really set to "Field List" (table/query seems better
choice for some reason)?
3. And what does he mean by setting "RowSource to a table Category"? Is that
custTbl in my case?
Kindly,
Mikael
Sweden
In first field I want to enter customber_number and then I'd like to to have
a list of all available invoices that belongs to that customer in the other
(multibox field).
Customer number is in one table (custTbl, CustID) and invoices in a second
table (invTbl, invNo).
Each table is related by the custID key.
Now, I have really tried to use this advice (from:
http://www.mvps.org/access/forms/frm0028.htm ):
Let's say you have two comboboxes, cbxCombo1 and cbxCombo2. The
RowSourceType of cbxCombo1 is set to "Field List" and RowSource to a table
Category. cbxCombo2 doesn't have anything under RowSource.
In this case, you can put code in the AfterUpdate event of cbxCombo1
that assigns the proper RowSource to cbxCombo2.
'**************** Code Start *************
Private Sub cbxCombo1_AfterUpdate()
Dim strSQL As String
strSQL = "Select " & Me!cbxCombo1
strSQL = strSQL & " from Categories"
Me!cbxCombo2.RowSourceType = "Table/Query"
Me!cbxCombo2.RowSource = strSQL
End Sub
'**************** Code End *************
But I can't get it to work.
1. What does "from Categories" in the SQL reference to? What would that
translate to in my case, invTble maybe?
2. Should cbxCombo1 really set to "Field List" (table/query seems better
choice for some reason)?
3. And what does he mean by setting "RowSource to a table Category"? Is that
custTbl in my case?
Kindly,
Mikael
Sweden