Drop Down Box VB Code

  • Thread starter Thread starter Rick
  • Start date Start date
R

Rick

OK, I'm having a problem with my drop boxes. I used the
wizard to create them so I don't know how to write the
code and here is what's wrong and what I need to do.

Wrong: When I select a record using a drop box, that
record is pulled and placed in the form. The record
changes in the form but at the bottom of the form, it
still shows I'm on record #1. When updating the new
record, record #1's last name changes to the same as the
individuals in the record I'm updating.

Need: Need to know how to write the code for the drop box
to pull from tblMember and place that individuals record
in the form with the record number at the bottom of the
form showing the correct record #.

Thanks
 
Rick,

Tables are an unordered repository for your data; they do not have record
numbers, per se. When you select a record using a drop-down, the reason it
is shown as Record 1 in your form is because it is the first record in the
record source of the form which matches your criteria. So, in the situation
you describe, Access is working "as designed".

hth,
 
OK but I'm confussed why it changes the last name of the
first record to the same last name as the current record?
Do you know how I can fix this? I tried to remove the
record source of MemberLastName but when I did that, the
form doesn't update with the new record. I'm stumped, can
you offer any ideas, suggestions?
 
Rick,

I think I may be "getting lost" somewhere between here:

1. > Wrong: When I select a record using a drop box, that
record is pulled and placed in the form. The record
changes in the form but at the bottom of the form, it
still shows I'm on record #1.

and here:

2. > When updating the new
record, record #1's last name changes to the same as the
individuals in the record I'm updating.

In 1. above, you indicate that you use a combo box to select an existing
record. Then, in 2. you refer to a "new record". Would you mind providing
more detail as to your form's design (single form, single main form with sub
form, etc.) and most important what you want to do with it.
 
Cheryl,

OK, my form is a main form pulling data from a query
(combinding tblMember and tblAppraisals) with a subform
using tblAppraisals as the data source. These forms are
joined using the PrimaryKey from tblMember and ForeignKey
from tblAppraisals, MemberID(autonumber).

Maybe this is the wrong set up but it pulls the data from
tblMember and automatically assigns the PrimaryKey as the
ForeignKey in the tblAppraisal. It works and it does
create the Appraisal I update/manage in the
frmManageActiveAppraisal (data source is the query). When
the appraisal is accomplished, the CompletedDate is
updated with the date the appraisal was accomplished. The
NextAppraisalDue field is automatically updated with the
NextAppraisalDue (in VB not assigned to the field) + 365
so we know when the Appraisal is due next year.

But when I select a member from the drop box and update
that record (not new, already created in tblMember but a
new Appraisal record is created so I can have multiple
Appraisals for one member (one to many relationship)).

What happens is this, when I open the
frmManageActiveApriasals, it shows the active Appraisal as
its supposed to but when I open another form called
frmManageMembers (data source of tblMember), the first
record now has the same last name as the individual I just
created the ActiveAppraisal on. If I create another
Appraisal, the first record in tblMember's will change to
the same last name of the appraisal I just created.
Basically, If I create five active Appraisals, the last
name in the first record of tblMember will change five
times.

I hope that makes sense and I hope you know how I can fix
it. Other words I will have to create a phantom first
record source so every time I create a new Appraisal it
won't matter if it changes the last name of the first
record but I don't want to do a work around, I want to do
it right the first time so I produce a reliable product.

Thanks and let me know if you need additional info. If
you do, e-mail me at: (e-mail address removed)

Thanks
 
Hi Rick,

My apologies for the delay in getting back to you. My first question
(hopefully, it will be the key): Is the drop-down (combo box field) on your
Main Form bound to a field in the underlying query for your Main Form?
 
Back
Top