how to choose my record

  • Thread starter Thread starter Tom
  • Start date Start date
T

Tom

I really haven't ANYTHING in the way of forms, other than run the
wizard. So to say I'm a beginner at forms is an understatement.

I have a table which uses an autonumber field as the primary key. I'd
like to have a form to use to update my records. But I don't know how
to go about choosing my record. I'm thinking a drop down list showing
my "Name" field would be what I want. (Or should I just feed the form
the key?)

I've tried using a drop down list, but it doesn't seem to work. I'm
assuming it's an event procedure like this:

Private Sub lbxDestID_LostFocus()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[DestID] = " & Str(Me![lbxDestID])
Me.Bookmark = rs.Bookmark

End Sub

but I don't know where to place it. On the form? Or a control? On
Got Focus? Lost Focus? Other?

I haven't been able to find any examples to try and copy, so I'm
really "flying blind" here.

Any help is appreciated.

Thanks in advance.

Tom
 
A proposal is to attack this with two simple forms and
one query.
First, a form with a combo or list box. Use the wizard to
create it. The data for this box comes from your table (the
one you mentioned). You should display what is needed to
select the correct record, and then tell the wizard to store
the key for use later (I think it asks if you want it to 'remember'
the data)

Next, build a query that displays all the fields of the record you
wish to be able to modify--in the criteria block of the ID field,
use the expression builder. Click on Forms, then the form with
the combo box/list box discussed above. It will have a name
like "combobox1" or something. Double click this and it will
appear in the big box at the top. It will say something like
Forms!Name_form!Combo1.

Close the box. Your query now returns only the one matching record.
Now build a form based on the new query and you can edit just the
record you are looking for.

On the first, selection, form, you can either have a button open
the second form, or have the second (query) form open on double click,
a change to the selection, etc.

Scott
 
I used your info, before using the "more robust" version. I got it to
work. Then I thought that I'd try the "robust" version. Now I can't
get it to compile.

I AM using DAO. I had to add:

Dim rs As DAO.Recordset

But I still get a compile error:

User-defined type not defined.

and what is highlighted is:

rs As DAO.Recordset

I admit I'm still somewhat "fuzzy" on this DAO and ADO stuff. My
books have next to nothing in them. I've tried reading technet on
MS's website, but still don't "get" it. And I can't seem to find ANY
docs that tell me what commands can go with what objects, etc. (So I
keep having to ask here.)

In any event, if I can't understand how to get the "robust" version
working, I guess I'll have to go back to the way it was before.

Thanks,

Tom
 
Back
Top