Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hiding feilds in a form based on the users input in a particular feil

Status
Not open for further replies.

oggstar

Technical User
Sep 8, 2001
18
0
0
AU
I want the field [OWNERS CONSENT] to be visible and editable only when the field [LI or DA Status]="DA".
(Both fields are in the same table)

I did try and use VB by doing the following.
I would right click the field [OWNERS CONSENT], build code followed by code builder.
Then I would type in the following,.

Private Sub OWNERS_CONSENT_AfterUpdate()
If [LI or DA Status]="DA" = True then
[OWNERS CONSENT].Visible = True
Else
[OWNERS CONSENT].Visible = False
End If
End Sub

This was unsuccessful, and ideas appreciated?

Can I do this as Access function or do I need to use Visual basic.
 
Try to use the same code but use it in the lost focus event.
please let me know.
 
Hi!

I think you have the correct event but you will need to put the code in the after update event of the [LI or DA Status] field.

hth
Jeff Bridgham
bridgham@purdue.edu
 
Thanks for the replys they were very helpful
I was using the wrong feild and the wrong event.
Lost focus did not seem to work however Got focus seemed to work well.

However the only problem is that when i close my database and then re-open it, it does not make the owners consent immediately invisbale if the status feild is low impact.

I actually have to change the feild [Status]and then it will work as i scroll through my 100 records. It appears to reset the databse until an action is taken.

Any ideas on how to overcome this problem is appreciated.
The code is shown below.

Private Sub Status_GotFocus
If [Status] = "Low Impact" = True Then
[OWNERS CONSENT].Visible = False
Else
[OWNERS CONSENT].Visible = True
End If
End Sub
 
Hi Oggstar,

You have the right code, however it really needs to be in the after update event of the Status field and also in the on current event of the form.

This will cause the consent field hide/show depending on the status field without you having to click into any boxes. Maq B-)
<insert witty signature here>
 
Thanks Marquis your a champion, 'it works'.

Howver what if i want the status to = &quot;low impact&quot; and &quot;on hold&quot; to be invisable.
I tryed typing in

or &quot;on hold&quot;
or
and &quot;on hold&quot;

This was unsuccusful, any ideas.

Private Sub Form_Current()
If [Status] = &quot;Low Impact&quot; or &quot;on hold&quot; = True Then
[OWNERS CONSENT].Visible = False
[Plans].Visible = False
Else
[OWNERS CONSENT].Visible = True
[Plans].Visible = True
End If

End Sub
 
Use a select case on your variable instead of an if statement if you can have more than 2 values. Look up the case statement in Access Help.

Select Case me!status
Case &quot;Low Impact&quot;
consent.visible = false
Case &quot;On Hold&quot;
consent.visible = false
Case &quot;High Impact&quot;
consent.visible = true
Case Else
consent.visible = true
End Select. Maq B-)
<insert witty signature here>
 
Thanks Maquis that has solved the problem.
 
Hello
I am trying to use the following code which has been succusfully adapeted in another datebase of mine. I have changed around the field names and relevent details.
However it is not working and the following message appaers
&quot;Run time errer 438, Property does not support this property or method&quot;

Any ideas appreciated
The Code is outlined below.


Private Sub Form_Current()

Select Case Me![LI or DA Status]
Case &quot;Low Impact&quot;
[PLANS recived].Visible = False

Case &quot;Low Impact request plans to confirm&quot;
[PLANS recived].Visible = False

Case Else
[PLANS recived].Visible = True
End Select

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top