-----Original Message-----
Andrew,
I would say the first thing to do is to make sure the listbox returns what
it is supposed to. To check, press Ctrl+G while the form is open and a name
is selected in the listbox; this will take you to the immediate window of
the VB editor. Type the following in there:
?Forms![MyFormName]![ListBoxName]
using the actual form and listbox name instead of my generic ones, and press
enter. Whatever the lsitbox returns will ne printed in the next line of the
immediate window, so you'll know. Is it indeed the value of the autonumber
field corresponding to the selected name?
If that's OK, then you need to check your DLookups, which should look
something like:
DLookup("[SomeField]","TableName","[IDFieldName]=" &
Forms![MyFormName]![ListBoxName])
If your DLookups were previously using a text field, it may be that there
are some extra quotes for text left around the listbox reference in the
expressions; if that's the case, they should be removed since the ID field
is numeric.
HTH,
Nikos
I did that and it wont select anything now. Could the
problem be the the ID Number is an autonumber and not a
text field.
-----Original Message-----
Andrew,
Having the ID number in your table is a very good start.
As a general rule,
using names as a PK is bad practice (but also a very
common mistake among
new users). Having said that, obviously you need to
change your desing so it
utilizes the ID field, and looks up the details based on
that. The trick is
to make the listbox display the surname and first name,
while it actually
returns the ID field. To do that, select the listbox in
form design, and
change its rowsource property (easiest way: invoke
thequery builder) so it
selects the ID field, surname field, first name field;
leave the bound
column property to 1, then go to the Format tab, set the
column count
property to 3 if different, and specify column widths in
the pertinent
property, making sure the first one is 0 so it doesn't
show in the list.
That's all there is to it! Now you can use the reference
to the listbox to
DLookup your detail textboxes on the ID field.
HTH,
Nikos
message
Hi
On the side of my form i have a list box and when you
click on the client names it brings there details up.
Only problem i have is that if two people have the same
surname it picks up the first person details. I can
change it to pick up the first name but that doesnt
solve
my problem.
Each client has an ID Number is it possible to use that
in
the list. If so can someone help me out
Thanks
Andrew
.
.