Navigate to record on a form and turn on and off fields

E

EJ

I have a form that feeds into a table. When I open the form, it shows the
first record. I would like to create an unbound control that navigates to
the record that I want to see. For example, when I open the form, the
information for Kenya pops up. I would like to see the information for
Tanzania. How do I create a control that will take me to the record for
Tanzania?

Also, on the form I have some Yes/No fields. For example, I have a field
that asks, Is this country endemic for this disease? If yes, then I want
other fields filled in (e.g. year, last outbreak, region of outbreak). If
no, I dont want the entry person to be able to fill in those fields. How do
I do this?

Thanks!
 
K

Keith Wilby

EJ said:
I have a form that feeds into a table. When I open the form, it shows the
first record. I would like to create an unbound control that navigates to
the record that I want to see. For example, when I open the form, the
information for Kenya pops up. I would like to see the information for
Tanzania. How do I create a control that will take me to the record for
Tanzania?

Have you tried using the built-in search facilities like [CTRL] F ?
Also, on the form I have some Yes/No fields. For example, I have a field
that asks, Is this country endemic for this disease? If yes, then I want
other fields filled in (e.g. year, last outbreak, region of outbreak). If
no, I dont want the entry person to be able to fill in those fields. How
do
I do this?

Thanks!

In the check box After Update event (untested):

If Me.chkMyCheckBox Then
Me.txtText1.Enabled = True
{etc}
Else
Me.txtText1.Enabled = False
{etc}
End If

where {etc} is the lines of code for all other affected text boxes. You'll
probably have to call this code from the form's After Update event too.

Keith.
www.keithwilby.co.uk
 
E

EJ

Thanks Keith for your prompt reply. I was hoping to have a control to search
from as many users will be using this and I think that it will be easier for
them to navigate and understand searching for a field then.

Regarding the second one, I am not that familiar with code, so I have a
couple of questions. The fields that I have are actually combo boxes with
yes/no, but I assume that the code would be similar? Also, would Text1 be
the variable name? How would you list the other variables at the end?

Keith Wilby said:
EJ said:
I have a form that feeds into a table. When I open the form, it shows the
first record. I would like to create an unbound control that navigates to
the record that I want to see. For example, when I open the form, the
information for Kenya pops up. I would like to see the information for
Tanzania. How do I create a control that will take me to the record for
Tanzania?

Have you tried using the built-in search facilities like [CTRL] F ?
Also, on the form I have some Yes/No fields. For example, I have a field
that asks, Is this country endemic for this disease? If yes, then I want
other fields filled in (e.g. year, last outbreak, region of outbreak). If
no, I dont want the entry person to be able to fill in those fields. How
do
I do this?

Thanks!

In the check box After Update event (untested):

If Me.chkMyCheckBox Then
Me.txtText1.Enabled = True
{etc}
Else
Me.txtText1.Enabled = False
{etc}
End If

where {etc} is the lines of code for all other affected text boxes. You'll
probably have to call this code from the form's After Update event too.

Keith.
www.keithwilby.co.uk
 
K

Keith Wilby

EJ said:
Thanks Keith for your prompt reply. I was hoping to have a control to
search
from as many users will be using this and I think that it will be easier
for
them to navigate and understand searching for a field then.

In my experience it's far easier to educate users to use the built-in
search, it's far more powerful and flexible than a roll-your-own solution
and you'll save yourself an awful lot of work.
Regarding the second one, I am not that familiar with code, so I have a
couple of questions. The fields that I have are actually combo boxes with
yes/no, but I assume that the code would be similar? Also, would Text1 be
the variable name? How would you list the other variables at the end?

In the example code "txtText1" is the name of your control (I assumed
wrongly that it's a text box). Change that to the name of your control
(combo box).

Keith.
 
J

John W. Vinson

I have a form that feeds into a table. When I open the form, it shows the
first record. I would like to create an unbound control that navigates to
the record that I want to see. For example, when I open the form, the
information for Kenya pops up. I would like to see the information for
Tanzania. How do I create a control that will take me to the record for
Tanzania?

Use the Combo Box Wizard. Click the "magic wand" icon on the toolbox, and
choose the Combo Box tool. Base the combo on your table of countries, and use
the wizard option "Use this combo box to find a record". Post back with more
details if you have trouble.
Also, on the form I have some Yes/No fields. For example, I have a field
that asks, Is this country endemic for this disease? If yes, then I want
other fields filled in (e.g. year, last outbreak, region of outbreak). If
no, I dont want the entry person to be able to fill in those fields. How do
I do this?

Well... you're making a rather serious design mistake. You should NOT have a
yes/no field in the table for each disease! That's good spreadsheet logic but
Access is emphatically not a spreadsheet; you also should not have some fields
dependent on other fields. Instead you should step back and look at the
normalization of your tables. I'd see (at a glance, not really knowing the
nature of your data, so this will be incomplete and may be incorrect) at least
three tables: Countries (with the UN country code as the primary key, country
name, other info about the country as an entity); Diseases (with records for
Measles, Cholera, HIV AIDS, all the miseries that afflict humankind); and
Outbreaks, with fields for CountryID (link to Countries), DiseaseID (link to
the primary key of Diseases), OutbreakDate, OutbreakRegion, and any other info
about this particular bout of illness. "Date of last outbreak" would not be
stored anywhere as it can easily be looked up using a query or DLookUp.
 

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

Top