From: Hannah on
Hello,
I'm a self-taught access newbie so please accept my apologies if the answer
to this is already out there and I just haven't recognised it!

I've got a frmCountry and a sfrmHarbours, each has a combo box on.
cboCountry (main form) lets you choose a country and cboHarbour (sub form)
lets you choose a harbour from that country. frmCountry also has all the
fields for country (e.g. contact person, address) and sfrm Harbour also has
all the fields about the harbour (number of vessels, comments, type). To get
the forms to open blank, I've used this code (although I realise this isn't
ideal and somebody elsewhere suggested using a filter but I've no idea how to
do this):

DoCmd.RunCommand acCmdRecordsGoToNew

Which is great because my form opens blank BUT as soon as I make a selection
in cboCountry, cboHarbour remains blank but a record still shows up in all
the Harbour fields. What can I do to get the cboHarbour AND Harbour fields to
remain blank until I make a selection in cboHarbour? Thanks already for your
help - the advice and support I've received from this group has been amazing!
Feel free to suggest ways to improve my design too - I've just sort of
muddled through so there may well be a much better way to be doing this!


From: Marshall Barton on
Hannah wrote:
>I've got a frmCountry and a sfrmHarbours, each has a combo box on.
>cboCountry (main form) lets you choose a country and cboHarbour (sub form)
>lets you choose a harbour from that country. frmCountry also has all the
>fields for country (e.g. contact person, address) and sfrm Harbour also has
>all the fields about the harbour (number of vessels, comments, type). To get
>the forms to open blank, I've used this code (although I realise this isn't
>ideal and somebody elsewhere suggested using a filter but I've no idea how to
>do this):
>
>DoCmd.RunCommand acCmdRecordsGoToNew
>
>Which is great because my form opens blank BUT as soon as I make a selection
>in cboCountry, cboHarbour remains blank but a record still shows up in all
>the Harbour fields. What can I do to get the cboHarbour AND Harbour fields to
>remain blank until I make a selection in cboHarbour?


Change the harbour form's record source to a query with a
criteria for the harbourID field:
=Forms!countryform.harboursubform.Form.harbourcombobox

--
Marsh
MVP [MS Access]
From: Hannah on
Hi Marshall,
Thanks for such a speedy reply! I tried doing what you said but I got a
message saying "Enter Parameter Value" and then the bit of code you gave me.
I've checked I entered it correctly and in the right place but beyond that
I'm a bit stumped about what's causing the problem. Could it be clashing with
other code? I previously had the cboHarbour record source as the Harbour
table. Thanks again for all your help! Hannah



"Marshall Barton" wrote:

> Hannah wrote:
> >I've got a frmCountry and a sfrmHarbours, each has a combo box on.
> >cboCountry (main form) lets you choose a country and cboHarbour (sub form)
> >lets you choose a harbour from that country. frmCountry also has all the
> >fields for country (e.g. contact person, address) and sfrm Harbour also has
> >all the fields about the harbour (number of vessels, comments, type). To get
> >the forms to open blank, I've used this code (although I realise this isn't
> >ideal and somebody elsewhere suggested using a filter but I've no idea how to
> >do this):
> >
> >DoCmd.RunCommand acCmdRecordsGoToNew
> >
> >Which is great because my form opens blank BUT as soon as I make a selection
> >in cboCountry, cboHarbour remains blank but a record still shows up in all
> >the Harbour fields. What can I do to get the cboHarbour AND Harbour fields to
> >remain blank until I make a selection in cboHarbour?
>
>
> Change the harbour form's record source to a query with a
> criteria for the harbourID field:
> =Forms!countryform.harboursubform.Form.harbourcombobox
>
> --
> Marsh
> MVP [MS Access]
> .
>
From: Marshall Barton on
Hannah wrote:
>Thanks for such a speedy reply! I tried doing what you said but I got a
>message saying "Enter Parameter Value" and then the bit of code you gave me.
>I've checked I entered it correctly and in the right place but beyond that
>I'm a bit stumped about what's causing the problem. Could it be clashing with
>other code? I previously had the cboHarbour record source as the Harbour
>table.


The fact that you were prompted to enter somethng means that
you misspelled whatever the prompt box was asking for.

You may be confused about what you were supposed to do. A
combo box does not have a record source, they do have a
RowSource. Either way, you should not mess with the combo
box.

You were supposed to change the **subform** RecordSource and
the thing I posted was only an example because you did not
provide the names of your main form, subform *control* (on
the main form) or combo box. You are supposed to replace
the dummy names I used with the real names you have for
those objects.

--
Marsh
MVP [MS Access]
From: Hannah on
Thanks Marshall. I did change the subform record source and I changed it
using the names of my own controls in place of your dummies so really not
sure what's making it go wrong? Any ideas? Thanks again for all your help.

"Marshall Barton" wrote:

> Hannah wrote:
> >Thanks for such a speedy reply! I tried doing what you said but I got a
> >message saying "Enter Parameter Value" and then the bit of code you gave me.
> >I've checked I entered it correctly and in the right place but beyond that
> >I'm a bit stumped about what's causing the problem. Could it be clashing with
> >other code? I previously had the cboHarbour record source as the Harbour
> >table.
>
>
> The fact that you were prompted to enter somethng means that
> you misspelled whatever the prompt box was asking for.
>
> You may be confused about what you were supposed to do. A
> combo box does not have a record source, they do have a
> RowSource. Either way, you should not mess with the combo
> box.
>
> You were supposed to change the **subform** RecordSource and
> the thing I posted was only an example because you did not
> provide the names of your main form, subform *control* (on
> the main form) or combo box. You are supposed to replace
> the dummy names I used with the real names you have for
> those objects.
>
> --
> Marsh
> MVP [MS Access]
> .
>
 |  Next  |  Last
Pages: 1 2
Prev: Form filter problem
Next: Format Memo field