A
AccessMan
I have a [One] table with two key fields, [x] and [y]. [One] has a
one-to-many relationship to [Many], the latter having foreign key fields [x]
and [y] and another key field [z].
Form [frmMany] has separate combo box controls for the two foreign key
fields [x] and [y] and a text box for the third key field [z].
When creating a new record with [frmMany], the user must select values for
[x] and [y], and then enter a value for [z].
Based on a great suggestion from this group, I'd like to modify the way that
the user creates new records. I would like them to select one record from an
unbound combo box control whose row source is a query that concatenates the
two key fields of table [One] into one field, then use VBA associated with
the BeforeUpdate event of this combo box to update the form controls for [x]
and [y] to the appropriate values.
My problem is with the DLookUp function in VBA. I can't get the syntax
right, and HELP is not helpful enough.
Here's the sql for the concatenation query and a start on the DLookUp
statements from the combo box event VBA.
qry One Concatenated: SELECT [x] & ", " & [y] AS xy, One.x, One.y, FROM One;
frmMany!x = DLookUp ("[x]", "qry One Concatenated", "[xy] =" & combo box
contents)
frmMany!y = DLookUp ("[y]", "qry One Concatenated", "[xy] =" & combo box
contents)
I'm not sure that frmMany!x is the correct syntax, and I definitely don't
understand the syntax for the criteris field. I know this probably isn't
that hard, but I'm very frustrated trying to understand the HELP.
one-to-many relationship to [Many], the latter having foreign key fields [x]
and [y] and another key field [z].
Form [frmMany] has separate combo box controls for the two foreign key
fields [x] and [y] and a text box for the third key field [z].
When creating a new record with [frmMany], the user must select values for
[x] and [y], and then enter a value for [z].
Based on a great suggestion from this group, I'd like to modify the way that
the user creates new records. I would like them to select one record from an
unbound combo box control whose row source is a query that concatenates the
two key fields of table [One] into one field, then use VBA associated with
the BeforeUpdate event of this combo box to update the form controls for [x]
and [y] to the appropriate values.
My problem is with the DLookUp function in VBA. I can't get the syntax
right, and HELP is not helpful enough.
Here's the sql for the concatenation query and a start on the DLookUp
statements from the combo box event VBA.
qry One Concatenated: SELECT [x] & ", " & [y] AS xy, One.x, One.y, FROM One;
frmMany!x = DLookUp ("[x]", "qry One Concatenated", "[xy] =" & combo box
contents)
frmMany!y = DLookUp ("[y]", "qry One Concatenated", "[xy] =" & combo box
contents)
I'm not sure that frmMany!x is the correct syntax, and I definitely don't
understand the syntax for the criteris field. I know this probably isn't
that hard, but I'm very frustrated trying to understand the HELP.