G
Guest
I would like to control which table is used in a DLookUp based on the value
in another field on a form?
in another field on a form?
azkayaker said:I would like to control which table is used in a DLookUp based on the value
in another field on a form?
I would like to control which table is used in a DLookUp based on the value
in another field on a form?
John W. Vinson said:I would like to control which table is used in a DLookUp based on the value
in another field on a form?
The second argument to DLookUp is a string value with the name of a table or
query. Often this will be a string constant ("MyTable") but it works just fine
using a variable name or a forms reference, just so that variable contains a
valid table name:
=DLookUp("[Fieldname]", [cboTable], "<some criteria>")
where cboTable is the name of a combo box with the table name in the combo's
bound column should work fine.
John W. Vinson [MVP]
The value in the combobox/field is not equal to the name of the table(s) and
is already a bound field for the value selected. Can I have more than one
bound field for a combo?
Otherwise
It is more of an If/Then ie If field value = ABC then use Table1, = DEF
then use Table 2.....ect
My request is that based on Field1's value the DLookUp uses a specific table
to fill one or more fields on the form with data from the corresponding table
based on Field2's value. Currently all you see is Field2's value.
As I understand you are saying I need a table the shows the correlation
between values in Field1 and the associated tables ie Dog...tblDog,
City....tblCity.
azkayaker said:As a followup - Would I add a str value for somefield ie strSomeFeld into the
code?:
Dim strTableName As String
Dim strSomeField As String
Select Case someotherfieldonaform
Case thisvalue
strTableName = "tableA"
strSomeField = "field1"
Case thatvalue
strTableName = "tableB"
strSomeField = "field2"
Case othervalue
strTableName = "tableC"
strSomeField = "field3"
Ok - i'll try this and add another field for the table names. Not being that
fluent with Access what is the comboboxname.Column(n) systax where n is the
zero based index of the field? Is n = the column number for the combo source?