Flattery will get you anywhere
Even when I use the wrong field names, you get it right!
Well, it depends on what you want to do. Let's say, for example, you want
to include the Animal's name it the dropdown so the user can see it. (I don't
know whether this is of any value to you, but it is an example).
First, add the field for the animal's name to the query you use for the
combo's row source. Then, make the combo's Column Count 2. You will also
have to set your column widths to make them wide enough to view in drop down
mode. Let's say you need 1/2 " for the number and 1.5" for the Name. It
would be .5";1.5"
Now the user can see both the tag number and the animal's name.
:
Klatuu,
It must be a wonderful feeling to know what you're doing!
This works
like a charm. I know you said this is the simplest form of doing this, so I'm
all ears for what else you can do. I figure the more I can learn about the
different ways to do the same thing, can only help me in the long run. I'm
all yours for as long as you want to teach me. As the 'grasshopper ' in the
old KungFu TV series would say, "Teach me Master."
Thanks so much,
RandyM
:
Okay, we can make this work. It will be a good learning experience for you.
First, take the Where condition out of your query. We are going to do this a
little differently.
With no further changes, the form will open with the first record in the
recordset displayed in your form. You will be able to navigate through the
records using the navigation buttons. Of course, what you want to do is to
be able to find a specific tag number. For that, we are going to add a combo
box to the form header section of your form. It will be an unbound control.
It's row source should be "SELECT TagNum FROM tblAnimals"
Now, when you open the form and dropdown the combo box, you will have a list
of all tag numbers. The user can either enter a number or select from the
list. Once they have made a selection, we will need some VBA code in the
After Update event of the combo box to do the lookup and tell us if the tag
number is not found:
For example purposes, we will assume the name of the combo box to be cboTagNum
Dim rst As Recordset
Set rst = Me.RecordsetClone
rst.FindFirst "TagNum = " & Me.cboTagNum
If rst.NoMatch Then
MsgBox "Tag Number " & Me.cboTagNum & " Not Found"
Else
Me.Bookmark = rst.Bookmark
End If
Set rst = Nothing
Now, this is the simplest form of doing this. There are several other
things that can be done, but first, see if you can get this to work for you.
:
Okay, that is a start, but how do you run the query?
:
Thanks Klatuu for responding. I'm not sure what code you're referring to, but
here's the SQL for the query.
SELECT tblOwners.*, tblAnimals.*, tblFees.*, tblAnimals.AnimalTagNum
FROM tblOwners INNER JOIN (tblAnimals INNER JOIN tblFees ON
tblAnimals.AnimalID = tblFees.AnimalID_FeeTbl) ON tblOwners.OwnerID =
tblAnimals.OwnerID_AnimalTbl
WHERE (((tblAnimals.AnimalTagNum)=[Enter TagNum to Lookup]));
If this is not what you need, please tell me exactly what and I'll try to
find it and post it. I'm still feeling my way thru Access, so sometimes
things that are simple to you 'pros' aren't so simple to me.
Thanks again for responding,
RandyM
:
Depends on how you are doing your look up. Post your code so we can give a
good response.
:
I have a query that asks for a tag number and then looks up and opens the
correct record. I would like to display a message if the user enters a tag
number that is not valid, but I don't know how. I think it would probably be
in an event, but I don't know which one and I'm not sure exactly what to
check for. If someone could help me out, I should would appreciate it.
Thanks,
RandyM