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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trouble with Visible property

Status
Not open for further replies.

NoelMG

Programmer
Dec 5, 2003
23
GB
I have a field in a form called Partner ID which I want to be visible only when DelegateType="Partner".

I have added the code for AfterUpdate of the relative field and on current for the form as follows:

Private Sub DelegateType_AfterUpdate()
Me!Partner_ID.Enabled = (DelegateType = “Partner”)
End Sub

and

Private Sub Form_Current()
Me!PartnerID.Enabled = (DelegateType = “Partner”)
End Sub

This works a treat, but when I scroll to the last record and try to add a new record, I get a "Run Time Error 13 - Type Mismatch".

Anybody know what's causing this and how I can get around it?

MTIA

NoelMG.
 
Well in a new record Delegate Type = NULL so you need to set it in a place where it does not dependent on each record seperately.

Maybe you want to write the code for adding a new record that it should always be visible?
 
You can use the Nz() function. That forces nulls to whatever you want ( "" by default).

So this should work:
Code:
Me!PartnerID.Enabled = (Nz(DelegateType) = “Partner”)

Dean :)
 
That's brilliant thanks, I fixed it using the Nz function!

I knew I'd get a quick answer off here!

Thanks,
Noel.

:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top