Toggling Forms

  • Thread starter Thread starter Steve
  • Start date Start date
S

Steve

Can you please help.

I have 2 forms that are more or less the same although I
use one for editing the information. I have locked all
the fields on the HPC form.

I would like to have a button on the HPC form that brings
up the HPC_Edit form and hides the HPC form. And when I
close the HPC_Edit form I would like to save the record
information and make the HPC form visible again, making
the HPC form visible.

I was given this sample code but I get "Else without IF"
errors.


Private Sub test_Click()

If Me![HPC].Visible = -1 Then Me![HPC].Visible = 0
Else: Me![HPC].Visible = -1

If Me![HPC_Edit].Visible = 0 Then Me![HPC_Edit].Visible
= -1
Else: Me![HPC_Edit].Visible = 0

End Sub

Please help.

Many thanks

Steve
 
Steve,

Actually it is the missing End If's that are probably the
problem. Try this format.


If Me![HPC].Visible = -1 Then
Me![HPC].Visible = 0
Else
Me![HPC].Visible = -1
End IF

If Me![HPC_Edit].Visible = 0 Then
Me![HPC_Edit].Visible = -1
Else
Me![HPC_Edit].Visible = 0
End If

Here is another more efficient way to toggle the visibility
as well....

Me![HPC].Visible = Not Me![HPC].Visible

Gary Miller
Sisters, OR
 
Thanks Gary

However, I now get the error:

HPC Database can't find the field 'HPC' referred to in
your expression.

Any ideas

Thanks

Steve
-----Original Message-----
Steve,

Actually it is the missing End If's that are probably the
problem. Try this format.


If Me![HPC].Visible = -1 Then
Me![HPC].Visible = 0
Else
Me![HPC].Visible = -1
End IF

If Me![HPC_Edit].Visible = 0 Then
Me![HPC_Edit].Visible = -1
Else
Me![HPC_Edit].Visible = 0
End If

Here is another more efficient way to toggle the visibility
as well....

Me![HPC].Visible = Not Me![HPC].Visible

Gary Miller
Sisters, OR

Steve said:
Can you please help.

I have 2 forms that are more or less the same although I
use one for editing the information. I have locked all
the fields on the HPC form.

I would like to have a button on the HPC form that brings
up the HPC_Edit form and hides the HPC form. And when I
close the HPC_Edit form I would like to save the record
information and make the HPC form visible again, making
the HPC form visible.

I was given this sample code but I get "Else without IF"
errors.


Private Sub test_Click()

If Me![HPC].Visible = -1 Then Me![HPC].Visible = 0
Else: Me![HPC].Visible = -1

If Me![HPC_Edit].Visible = 0 Then Me![HPC_Edit].Visible
= -1
Else: Me![HPC_Edit].Visible = 0

End Sub

Please help.

Many thanks

Steve


.
 
Steve,

Recheck the names of the fields that you are trying to hide
and show. It is saying that HPC is not a valid field name on
your form. Your 'Me!????' needs to refer to the exact name
of your field and if there are spaces in the name you need
to enclose the name with brackets Me![name with spaces].

Gary Miller

Thanks Gary

However, I now get the error:

HPC Database can't find the field 'HPC' referred to in
your expression.

Any ideas

Thanks

Steve
-----Original Message-----
Steve,

Actually it is the missing End If's that are probably the
problem. Try this format.


If Me![HPC].Visible = -1 Then
Me![HPC].Visible = 0
Else
Me![HPC].Visible = -1
End IF

If Me![HPC_Edit].Visible = 0 Then
Me![HPC_Edit].Visible = -1
Else
Me![HPC_Edit].Visible = 0
End If

Here is another more efficient way to toggle the visibility
as well....

Me![HPC].Visible = Not Me![HPC].Visible

Gary Miller
Sisters, OR

Steve said:
Can you please help.

I have 2 forms that are more or less the same although I
use one for editing the information. I have locked all
the fields on the HPC form.

I would like to have a button on the HPC form that brings
up the HPC_Edit form and hides the HPC form. And when I
close the HPC_Edit form I would like to save the record
information and make the HPC form visible again, making
the HPC form visible.

I was given this sample code but I get "Else without IF"
errors.


Private Sub test_Click()

If Me![HPC].Visible = -1 Then Me![HPC].Visible = 0
Else: Me![HPC].Visible = -1

If Me![HPC_Edit].Visible = 0 Then Me![HPC_Edit].Visible
= -1
Else: Me![HPC_Edit].Visible = 0

End Sub

Please help.

Many thanks

Steve


.
 
Gary

HPC and HPD_Edit are not fields, they are forms. I need
to turn HPC off when I edit and the vice versa when I
save.

Thanks

Steve
-----Original Message-----
Steve,

Recheck the names of the fields that you are trying to hide
and show. It is saying that HPC is not a valid field name on
your form. Your 'Me!????' needs to refer to the exact name
of your field and if there are spaces in the name you need
to enclose the name with brackets Me![name with spaces].

Gary Miller

Thanks Gary

However, I now get the error:

HPC Database can't find the field 'HPC' referred to in
your expression.

Any ideas

Thanks

Steve
-----Original Message-----
Steve,

Actually it is the missing End If's that are probably the
problem. Try this format.


If Me![HPC].Visible = -1 Then
Me![HPC].Visible = 0
Else
Me![HPC].Visible = -1
End IF

If Me![HPC_Edit].Visible = 0 Then
Me![HPC_Edit].Visible = -1
Else
Me![HPC_Edit].Visible = 0
End If

Here is another more efficient way to toggle the visibility
as well....

Me![HPC].Visible = Not Me![HPC].Visible

Gary Miller
Sisters, OR

message Can you please help.

I have 2 forms that are more or less the same
although
I
use one for editing the information. I have locked all
the fields on the HPC form.

I would like to have a button on the HPC form that brings
up the HPC_Edit form and hides the HPC form. And when I
close the HPC_Edit form I would like to save the record
information and make the HPC form visible again, making
the HPC form visible.

I was given this sample code but I get "Else without IF"
errors.


Private Sub test_Click()

If Me![HPC].Visible = -1 Then Me![HPC].Visible = 0
Else: Me![HPC].Visible = -1

If Me![HPC_Edit].Visible = 0 Then Me! [HPC_Edit].Visible
= -1
Else: Me![HPC_Edit].Visible = 0

End Sub

Please help.

Many thanks

Steve


.


.
 
Oh, OK. By your syntax I thought we were dealing with
controls.

If they are forms, you can't use the 'Me' word, at least not
for both of them, as that refers to the parent form of the
code. If you are hiding the form that the code is running
from you can use...

Me.Visible = False or Me.Visible = 0

For the other form you will need the full reference for the
form...

Forms!HPC.Visible = False

Gary Miller
Sisters, OR


Steve said:
Gary

HPC and HPD_Edit are not fields, they are forms. I need
to turn HPC off when I edit and the vice versa when I
save.

Thanks

Steve
-----Original Message-----
Steve,

Recheck the names of the fields that you are trying to hide
and show. It is saying that HPC is not a valid field name on
your form. Your 'Me!????' needs to refer to the exact name
of your field and if there are spaces in the name you need
to enclose the name with brackets Me![name with spaces].

Gary Miller

Thanks Gary

However, I now get the error:

HPC Database can't find the field 'HPC' referred to in
your expression.

Any ideas

Thanks

Steve
-----Original Message-----
Steve,

Actually it is the missing End If's that are probably the
problem. Try this format.


If Me![HPC].Visible = -1 Then
Me![HPC].Visible = 0
Else
Me![HPC].Visible = -1
End IF

If Me![HPC_Edit].Visible = 0 Then
Me![HPC_Edit].Visible = -1
Else
Me![HPC_Edit].Visible = 0
End If

Here is another more efficient way to toggle the
visibility
as well....

Me![HPC].Visible = Not Me![HPC].Visible

Gary Miller
Sisters, OR

message Can you please help.

I have 2 forms that are more or less the same although
I
use one for editing the information. I have locked all
the fields on the HPC form.

I would like to have a button on the HPC form that
brings
up the HPC_Edit form and hides the HPC form. And when I
close the HPC_Edit form I would like to save the record
information and make the HPC form visible again, making
the HPC form visible.

I was given this sample code but I get "Else without
IF"
errors.


Private Sub test_Click()

If Me![HPC].Visible = -1 Then Me![HPC].Visible = 0
Else: Me![HPC].Visible = -1

If Me![HPC_Edit].Visible = 0 Then Me! [HPC_Edit].Visible
= -1
Else: Me![HPC_Edit].Visible = 0

End Sub

Please help.

Many thanks

Steve


.


.
 
Gary

Thanks very much for you help. Now have it.

Sorry to be a pain.

Cheers

Steve
-----Original Message-----
Oh, OK. By your syntax I thought we were dealing with
controls.

If they are forms, you can't use the 'Me' word, at least not
for both of them, as that refers to the parent form of the
code. If you are hiding the form that the code is running
from you can use...

Me.Visible = False or Me.Visible = 0

For the other form you will need the full reference for the
form...

Forms!HPC.Visible = False

Gary Miller
Sisters, OR


Steve said:
Gary

HPC and HPD_Edit are not fields, they are forms. I need
to turn HPC off when I edit and the vice versa when I
save.

Thanks

Steve
-----Original Message-----
Steve,

Recheck the names of the fields that you are trying to hide
and show. It is saying that HPC is not a valid field name on
your form. Your 'Me!????' needs to refer to the exact name
of your field and if there are spaces in the name you need
to enclose the name with brackets Me![name with spaces].

Gary Miller

Thanks Gary

However, I now get the error:

HPC Database can't find the field 'HPC' referred to in
your expression.

Any ideas

Thanks

Steve
-----Original Message-----
Steve,

Actually it is the missing End If's that are
probably
the
problem. Try this format.


If Me![HPC].Visible = -1 Then
Me![HPC].Visible = 0
Else
Me![HPC].Visible = -1
End IF

If Me![HPC_Edit].Visible = 0 Then
Me![HPC_Edit].Visible = -1
Else
Me![HPC_Edit].Visible = 0
End If

Here is another more efficient way to toggle the
visibility
as well....

Me![HPC].Visible = Not Me![HPC].Visible

Gary Miller
Sisters, OR

message [email protected]...
Can you please help.

I have 2 forms that are more or less the same although
I
use one for editing the information. I have
locked
all
the fields on the HPC form.

I would like to have a button on the HPC form that
brings
up the HPC_Edit form and hides the HPC form. And when I
close the HPC_Edit form I would like to save the record
information and make the HPC form visible again, making
the HPC form visible.

I was given this sample code but I get "Else without
IF"
errors.


Private Sub test_Click()

If Me![HPC].Visible = -1 Then Me![HPC].Visible = 0
Else: Me![HPC].Visible = -1

If Me![HPC_Edit].Visible = 0 Then Me! [HPC_Edit].Visible
= -1
Else: Me![HPC_Edit].Visible = 0

End Sub

Please help.

Many thanks

Steve


.



.


.
 
Back
Top