Requering and Forms

S

SharynInCambodia

Hi, I have a problem with a form. I have designed a form for entering
information for a village (which is further defined by a commune, district
and province - ie. you first choose which province, then which district, then
which commune and finally which village). I have place name tables that list
all the respective place names. When I choose a province and then go to
choose a district, it filters the district names to the province that i
chose. Once a district is chosen, then the communes are filtered to those
communes in that district, and so forth, through till we choose a village.
This works by defining criteria, but then if i make a change in any of the
place name fields selected, it does not requery. So, i have used a requery
code in AfterUpdate. Saved in the fields is the primary key (a number and
not the place name) - but it displays the place name (as it should be).

This then works great - except when i go to the next record to enter or
edit, which also works - but then on returning to the first record, it is
requeried according to other record and the old names are not displayed but
names based on the requery in the other record. And this is where i am
stuck!

I would really appreciate any help. Thank you thank you!
 
J

Jeanette Cunningham

Hi SharynInCambodia,
check that the combos for commune, district, province etc are unbound. The
only bound combo for this will be the combo for village.

Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
S

SharynInCambodia

Thanks Jeanette for the help. Sorry i haven't been able to get internet for
the last week so only just got your response. Aren't the commune, district,
province combo boxes bound to the tables that they are querying from? For
the properties of the combobox they are currently bound to the column that i
want to store (Province ID etc.) Unless i am looking at another place for
the combo box to be bound.
thanks again!

Actually, just tested - for bound column, i typed in unbound (and took out
the column number). seems to help a bit. i'll keep testing that. Thanks!!
may have solved my problem.
 
J

Jeanette Cunningham

Binding a combo means that when you make a selection in the combo, your
selection is saved in the table, in the field the combo is bound to.
If the combo is unbound, it still uses a table as its row source. The
difference is that you can select from the combo without saving the
selection back in a table bound to your form.
 
S

SharynInCambodia

Hi Jeanette, just back online again - haven't been able to get hooked up for
a while.
thanks for the explanation-- i just worked that out after i went home and
tried again what you explained. So it didn't quite solve my problem. the
problem is that i actually want to store the look ups in the underlying table
which means that whenever i query on the next record it changes whatever the
displayed on the previous record. Not sure if i am being very clear! I'll
try writing it out again and see if i can be clearer.
Thanks so much!
 
J

Jeanette Cunningham

Would you post the names of the relevant tables, the primary key and foreign
key for the table, and the relationships between the tables.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
S

SharynInCambodia

Yes,
I have relevant tables etc. as follows:
AreaProvince with primary key ProvinceID
AreaDistrict with primary key DistrictID and a foreign key ProvinceID
AreaCommune with primary key CommuneID and foreign keys ProvinceID and
DistrictID
AreaVillage with primary key VillageID and foriegn keys ProvinceID,
DistrictID and CommuneID
Now, those tables are just the lookup tables which have the ID codes (which
are official codes that they use nationally) and the names of each area.

The tables that i am trying to enter data in via these forms are for
recording various details of our project's activity in each village (we are
an development NGO working in communities). There are a number of these
tables for different stages of activity. For example i have one recording
identified problems and solutions (TableName VillageProblemAnalysis) so for
that i have an autonumber ID for - primary key and then i have the province,
district, commune and village IDs stored. this looks up the area tables
listed earlier. these 4 IDs together identify the exact village. the combo
boxes display the names but the IDs are stored. the combo boxes work great
for adding a new record but when i go back and look at previous records the
names displayed for the areas have changed according to the latest record
entered.

for example if i enter:
Record 1: provinceID=13 (preah vihear); districtID=02 (rovieng);
communeID=01 (robieb); villageID=04 (tandrak)
Record 2: provinceID=17 (siem reap); districtID=01 (angkor chum);
communeID=02 (Don peang); villageID=01 (tanout)

now when i go back to look at the first record, after i enter the second
record, the names in the district field show the names based on the last
query on the last record (so for record 1 it changes to show the district #02
in siem reap province instead of preah vihear province because Siem Reap was
selected in the second query) - the underlying ID number is still the same
and correct. if i didn't want to display the names it'd be fine.

not sure if this is any clearer! thanks. i am in civilization for a few
days so can respond quicker for the rest of the week!
 
J

Jeanette Cunningham

This is like a database I did using Region, District, Park, Track.

You are storing too many IDs in the VillageProblemAnalysis table.
You only need the ID for Village in this table.
Access manages the Provinces, Districts and Communes for you in the separate
tables for these things.

Build a selection form where user can choose the province and the district.
You can have an unbound combo to choose the Province.
You can have an unbound combo to choose the District.
The row source for the District combo is filtered to show only the Districts
for the Province chosen.

That means that neither the ProvinceID or DistrictID are stored in tables
bound to this form.
The control source for both Province combo and district should be empty.

The combo for Communes will be on a form based on the Communes table and the
Village combo will be on a subform (based on the village table) on the
Communes form.
The communes main form and village subform allow you to associate each
village with its correct commune.

After user has chosen which village, you can open a form based on the
table - VillageProblemAnalysis

On the subform on the communes form, you can put a button to open a form to
add new problems or edit problems on the form you will build that is based
on the VillageProblemAnaylsis table.

DoCmd.OpenForm "frmVillageProblemAnalysis", , , "[VillageID] = " &
Me.VillageID

-assuming that the button is on the village subform, the above single line
of code goes on the button on the village subform.



Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
S

SharynInCambodia

I think i get what you are saying. actually, i misinformed you about the
primary keys - on the area name tables for district and down, the primary
keys are a multiple field keys (eg. ProvinceID+DistrictID or
ProvinceID+DistrictID+CommuneID). does this have implications or do i need
to create a single field for the key in village (easily done)? i still need
to digest and try what you have said but is there any way to avoid subforms
(i have plenty coming off it already). so that i can keep the village
selection on the main form and still display the selected village, commune,
district, province etc? trying to keep it simple
thanks again!

Jeanette Cunningham said:
This is like a database I did using Region, District, Park, Track.

You are storing too many IDs in the VillageProblemAnalysis table.
You only need the ID for Village in this table.
Access manages the Provinces, Districts and Communes for you in the separate
tables for these things.

Build a selection form where user can choose the province and the district.
You can have an unbound combo to choose the Province.
You can have an unbound combo to choose the District.
The row source for the District combo is filtered to show only the Districts
for the Province chosen.

That means that neither the ProvinceID or DistrictID are stored in tables
bound to this form.
The control source for both Province combo and district should be empty.

The combo for Communes will be on a form based on the Communes table and the
Village combo will be on a subform (based on the village table) on the
Communes form.
The communes main form and village subform allow you to associate each
village with its correct commune.

After user has chosen which village, you can open a form based on the
table - VillageProblemAnalysis

On the subform on the communes form, you can put a button to open a form to
add new problems or edit problems on the form you will build that is based
on the VillageProblemAnaylsis table.

DoCmd.OpenForm "frmVillageProblemAnalysis", , , "[VillageID] = " &
Me.VillageID

-assuming that the button is on the village subform, the above single line
of code goes on the button on the village subform.



Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia



SharynInCambodia said:
Yes,
I have relevant tables etc. as follows:
AreaProvince with primary key ProvinceID
AreaDistrict with primary key DistrictID and a foreign key ProvinceID
AreaCommune with primary key CommuneID and foreign keys ProvinceID and
DistrictID
AreaVillage with primary key VillageID and foriegn keys ProvinceID,
DistrictID and CommuneID
Now, those tables are just the lookup tables which have the ID codes
(which
are official codes that they use nationally) and the names of each area.

The tables that i am trying to enter data in via these forms are for
recording various details of our project's activity in each village (we
are
an development NGO working in communities). There are a number of these
tables for different stages of activity. For example i have one recording
identified problems and solutions (TableName VillageProblemAnalysis) so
for
that i have an autonumber ID for - primary key and then i have the
province,
district, commune and village IDs stored. this looks up the area tables
listed earlier. these 4 IDs together identify the exact village. the
combo
boxes display the names but the IDs are stored. the combo boxes work
great
for adding a new record but when i go back and look at previous records
the
names displayed for the areas have changed according to the latest record
entered.

for example if i enter:
Record 1: provinceID=13 (preah vihear); districtID=02 (rovieng);
communeID=01 (robieb); villageID=04 (tandrak)
Record 2: provinceID=17 (siem reap); districtID=01 (angkor chum);
communeID=02 (Don peang); villageID=01 (tanout)

now when i go back to look at the first record, after i enter the second
record, the names in the district field show the names based on the last
query on the last record (so for record 1 it changes to show the district
#02
in siem reap province instead of preah vihear province because Siem Reap
was
selected in the second query) - the underlying ID number is still the same
and correct. if i didn't want to display the names it'd be fine.

not sure if this is any clearer! thanks. i am in civilization for a few
days so can respond quicker for the rest of the week!
 
J

Jeanette Cunningham

From the info you posted so far, it would be so much easier if you removed
the multiple primary key fields from the province, district and commune
tables.
It would be a good idea for you to post any other tables you have now.
Getting the tables set up correctly to suit your purposes for this database
is the most important thing to do before you go any further.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia


SharynInCambodia said:
I think i get what you are saying. actually, i misinformed you about the
primary keys - on the area name tables for district and down, the primary
keys are a multiple field keys (eg. ProvinceID+DistrictID or
ProvinceID+DistrictID+CommuneID). does this have implications or do i
need
to create a single field for the key in village (easily done)? i still
need
to digest and try what you have said but is there any way to avoid
subforms
(i have plenty coming off it already). so that i can keep the village
selection on the main form and still display the selected village,
commune,
district, province etc? trying to keep it simple
thanks again!

Jeanette Cunningham said:
This is like a database I did using Region, District, Park, Track.

You are storing too many IDs in the VillageProblemAnalysis table.
You only need the ID for Village in this table.
Access manages the Provinces, Districts and Communes for you in the
separate
tables for these things.

Build a selection form where user can choose the province and the
district.
You can have an unbound combo to choose the Province.
You can have an unbound combo to choose the District.
The row source for the District combo is filtered to show only the
Districts
for the Province chosen.

That means that neither the ProvinceID or DistrictID are stored in tables
bound to this form.
The control source for both Province combo and district should be empty.

The combo for Communes will be on a form based on the Communes table and
the
Village combo will be on a subform (based on the village table) on the
Communes form.
The communes main form and village subform allow you to associate each
village with its correct commune.

After user has chosen which village, you can open a form based on the
table - VillageProblemAnalysis

On the subform on the communes form, you can put a button to open a form
to
add new problems or edit problems on the form you will build that is
based
on the VillageProblemAnaylsis table.

DoCmd.OpenForm "frmVillageProblemAnalysis", , , "[VillageID] = " &
Me.VillageID

-assuming that the button is on the village subform, the above single
line
of code goes on the button on the village subform.



Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia



SharynInCambodia said:
Yes,
I have relevant tables etc. as follows:
AreaProvince with primary key ProvinceID
AreaDistrict with primary key DistrictID and a foreign key ProvinceID
AreaCommune with primary key CommuneID and foreign keys ProvinceID and
DistrictID
AreaVillage with primary key VillageID and foriegn keys ProvinceID,
DistrictID and CommuneID
Now, those tables are just the lookup tables which have the ID codes
(which
are official codes that they use nationally) and the names of each
area.

The tables that i am trying to enter data in via these forms are for
recording various details of our project's activity in each village (we
are
an development NGO working in communities). There are a number of
these
tables for different stages of activity. For example i have one
recording
identified problems and solutions (TableName VillageProblemAnalysis) so
for
that i have an autonumber ID for - primary key and then i have the
province,
district, commune and village IDs stored. this looks up the area
tables
listed earlier. these 4 IDs together identify the exact village. the
combo
boxes display the names but the IDs are stored. the combo boxes work
great
for adding a new record but when i go back and look at previous records
the
names displayed for the areas have changed according to the latest
record
entered.

for example if i enter:
Record 1: provinceID=13 (preah vihear); districtID=02 (rovieng);
communeID=01 (robieb); villageID=04 (tandrak)
Record 2: provinceID=17 (siem reap); districtID=01 (angkor chum);
communeID=02 (Don peang); villageID=01 (tanout)

now when i go back to look at the first record, after i enter the
second
record, the names in the district field show the names based on the
last
query on the last record (so for record 1 it changes to show the
district
#02
in siem reap province instead of preah vihear province because Siem
Reap
was
selected in the second query) - the underlying ID number is still the
same
and correct. if i didn't want to display the names it'd be fine.

not sure if this is any clearer! thanks. i am in civilization for a
few
days so can respond quicker for the rest of the week!



:

Would you post the names of the relevant tables, the primary key and
foreign
key for the table, and the relationships between the tables.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia


in
message Hi Jeanette, just back online again - haven't been able to get
hooked
up
for
a while.
thanks for the explanation-- i just worked that out after i went
home
and
tried again what you explained. So it didn't quite solve my
problem.
the
problem is that i actually want to store the look ups in the
underlying
table
which means that whenever i query on the next record it changes
whatever
the
displayed on the previous record. Not sure if i am being very
clear!
I'll
try writing it out again and see if i can be clearer.
Thanks so much!

:

Binding a combo means that when you make a selection in the combo,
your
selection is saved in the table, in the field the combo is bound
to.
If the combo is unbound, it still uses a table as its row source.
The
difference is that you can select from the combo without saving the
selection back in a table bound to your form.



"SharynInCambodia" <[email protected]>
wrote
in
message Thanks Jeanette for the help. Sorry i haven't been able to get
internet
for
the last week so only just got your response. Aren't the
commune,
district,
province combo boxes bound to the tables that they are querying
from?
For
the properties of the combobox they are currently bound to the
column
that
i
want to store (Province ID etc.) Unless i am looking at another
place
for
the combo box to be bound.
thanks again!

Actually, just tested - for bound column, i typed in unbound (and
took
out
the column number). seems to help a bit. i'll keep testing
that.
Thanks!!
may have solved my problem.

:

Hi SharynInCambodia,
check that the combos for commune, district, province etc are
unbound.
The
only bound combo for this will be the combo for village.

Jeanette Cunningham MS Access MVP -- Melbourne Victoria
Australia


"SharynInCambodia" <[email protected]>
wrote
in
message
Hi, I have a problem with a form. I have designed a form for
entering
information for a village (which is further defined by a
commune,
district
and province - ie. you first choose which province, then which
district,
then
which commune and finally which village). I have place name
tables
that
list
all the respective place names. When I choose a province and
then
go
to
choose a district, it filters the district names to the
province
that i
chose. Once a district is chosen, then the communes are
filtered
to
those
communes in that district, and so forth, through till we
choose a
village.
This works by defining criteria, but then if i make a change
in
any
of
the
place name fields selected, it does not requery. So, i have
used
a
requery
code in AfterUpdate. Saved in the fields is the primary key
(a
number
and
not the place name) - but it displays the place name (as it
should
be).

This then works great - except when i go to the next record to
enter
or
edit, which also works - but then on returning to the first
record,
it
is
requeried according to other record and the old names are not
displayed
but
names based on the requery in the other record. And this is
where i
am
stuck!

I would really appreciate any help. Thank you thank you!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

code level! 1
question on Combobox 1
Mail Merge Help 1
Form Filter question 1
Count problem 1
Data entry base on Listboxes 1
Forms offline? 1
Percent Help 2

Top