Open form and activate a filed

  • Thread starter Thread starter Elisa
  • Start date Start date
E

Elisa

Hello everyboby,
could u please help me with two problems I have with forms:
1. given:
- a form "A" whose data are from a query "B"
- the field "b1" from "B" is linked to a field ("c1) of an other form
"C" (criteria:like[forms]![C].[c1])
I have to block the open form "A" if the query B gives no result for
the chosen data cointained in c1. The form A must allow the insert new
record though, if the query B gives results for the data in c1.

2. In a form I have two fields, I need one field be activated only if
the other is true.

I am using Windows XP, Microsoft Access 2002.
Thank you in advance,
Elisa
 
Hi Elisa,

Elisa said:
Hello everyboby,
could u please help me with two problems I have with forms:
1. given:
- a form "A" whose data are from a query "B"
- the field "b1" from "B" is linked to a field ("c1) of an other form
"C" (criteria:like[forms]![C].[c1])
I have to block the open form "A" if the query B gives no result for
the chosen data cointained in c1. The form A must allow the insert new
record though, if the query B gives results for the data in c1.

Instead of blocking the opening of the form you should go ahead and open
form A and on the forms On Open event check to see if there is data and
cancel the opening of the form if there isn't.

If Me.HasData then Cancel = True
2. In a form I have two fields, I need one field be activated only if
the other is true.

In the forms On Current event put

Me!NameOfBoxToShow.Enabled = Me!NameOfTrueFalseItem

This will activate/deactive the second box depending on the state of the
first box. You also need to call this when the user changes the true/false
box so copy this code to the AfterUpdate event of the true/false box.

Kelvin
 
THANK YOU KELVIN,
but where do I have to put these strings you wrote?
I put them in the form propierties, on open event, but it says it
can't recognize the macro, then I tried with the code, but still it
doesn't work.
cheers
elisa


Kelvin said:
Hi Elisa,

Elisa said:
Hello everyboby,
could u please help me with two problems I have with forms:
1. given:
- a form "A" whose data are from a query "B"
- the field "b1" from "B" is linked to a field ("c1) of an other form
"C" (criteria:like[forms]![C].[c1])
I have to block the open form "A" if the query B gives no result for
the chosen data cointained in c1. The form A must allow the insert new
record though, if the query B gives results for the data in c1.

Instead of blocking the opening of the form you should go ahead and open
form A and on the forms On Open event check to see if there is data and
cancel the opening of the form if there isn't.

If Me.HasData then Cancel = True
2. In a form I have two fields, I need one field be activated only if
the other is true.

In the forms On Current event put

Me!NameOfBoxToShow.Enabled = Me!NameOfTrueFalseItem

This will activate/deactive the second box depending on the state of the
first box. You also need to call this when the user changes the true/false
box so copy this code to the AfterUpdate event of the true/false box.

Kelvin
I am using Windows XP, Microsoft Access 2002.
Thank you in advance,
Elisa
 
I've Done it!
thank u v v much Kelvin!
have a nice day

THANK YOU KELVIN,
but where do I have to put these strings you wrote?
I put them in the form propierties, on open event, but it says it
can't recognize the macro, then I tried with the code, but still it
doesn't work.
cheers
elisa


Kelvin said:
Hi Elisa,

Elisa said:
Hello everyboby,
could u please help me with two problems I have with forms:
1. given:
- a form "A" whose data are from a query "B"
- the field "b1" from "B" is linked to a field ("c1) of an other form
"C" (criteria:like[forms]![C].[c1])
I have to block the open form "A" if the query B gives no result for
the chosen data cointained in c1. The form A must allow the insert new
record though, if the query B gives results for the data in c1.

Instead of blocking the opening of the form you should go ahead and open
form A and on the forms On Open event check to see if there is data and
cancel the opening of the form if there isn't.

If Me.HasData then Cancel = True
2. In a form I have two fields, I need one field be activated only if
the other is true.

In the forms On Current event put

Me!NameOfBoxToShow.Enabled = Me!NameOfTrueFalseItem

This will activate/deactive the second box depending on the state of the
first box. You also need to call this when the user changes the true/false
box so copy this code to the AfterUpdate event of the true/false box.

Kelvin
I am using Windows XP, Microsoft Access 2002.
Thank you in advance,
Elisa
 
In problem 1. how come the command
If Me.HasData then Cancel = True
is not recognized? it seems that HasData does not exist.
Is there another way to give this command?
cheers
Kelvin said:
Hi Elisa,

Elisa said:
Hello everyboby,
could u please help me with two problems I have with forms:
1. given:
- a form "A" whose data are from a query "B"
- the field "b1" from "B" is linked to a field ("c1) of an other form
"C" (criteria:like[forms]![C].[c1])
I have to block the open form "A" if the query B gives no result for
the chosen data cointained in c1. The form A must allow the insert new
record though, if the query B gives results for the data in c1.

Instead of blocking the opening of the form you should go ahead and open
form A and on the forms On Open event check to see if there is data and
cancel the opening of the form if there isn't.

If Me.HasData then Cancel = True
2. In a form I have two fields, I need one field be activated only if
the other is true.

In the forms On Current event put

Me!NameOfBoxToShow.Enabled = Me!NameOfTrueFalseItem

This will activate/deactive the second box depending on the state of the
first box. You also need to call this when the user changes the true/false
box so copy this code to the AfterUpdate event of the true/false box.

Kelvin
I am using Windows XP, Microsoft Access 2002.
Thank you in advance,
Elisa
 
Elisa,

I apologize, the HasData is only for reports. To check if the form has data
just check to see if there is a value in the primary key field or some other
field that will always have a value. If you don't have this field showing
on your form, then add it and make it invisible. Then you can use something
like the following in the On Load event of the form.

If IsNull(Me!NameOfField) then Cancel=True

If the query if empty, then IsNull() will be true and will cancel the
opening of the form.

Kelvin

Elisa said:
In problem 1. how come the command
If Me.HasData then Cancel = True
is not recognized? it seems that HasData does not exist.
Is there another way to give this command?
cheers
"Kelvin" <[email protected]> wrote in message
Hi Elisa,

Hello everyboby,
could u please help me with two problems I have with forms:
1. given:
- a form "A" whose data are from a query "B"
- the field "b1" from "B" is linked to a field ("c1) of an other form
"C" (criteria:like[forms]![C].[c1])
I have to block the open form "A" if the query B gives no result for
the chosen data cointained in c1. The form A must allow the insert new
record though, if the query B gives results for the data in c1.

Instead of blocking the opening of the form you should go ahead and open
form A and on the forms On Open event check to see if there is data and
cancel the opening of the form if there isn't.

If Me.HasData then Cancel = True

2. In a form I have two fields, I need one field be activated only if
the other is true.

In the forms On Current event put

Me!NameOfBoxToShow.Enabled = Me!NameOfTrueFalseItem

This will activate/deactive the second box depending on the state of the
first box. You also need to call this when the user changes the true/false
box so copy this code to the AfterUpdate event of the true/false box.

Kelvin

I am using Windows XP, Microsoft Access 2002.
Thank you in advance,
Elisa
 
Back
Top