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

Need help with an IF THEN statement 1

Status
Not open for further replies.

SmallTime

Technical User
May 17, 2004
127
GB
I have a subform ‘FrmForwardAddView’ which contains a field ‘ForwardAddID’. The main form is called ‘FrmLiveApplicantView’.
If ForwardAddID is null (no record exists) then I’d like a button on the main form ‘CmdOpenFrmSmallView’ to be visible otherwise it shouldn’t be visible.

I’ve tried the following on the OnOpen event of the main form but it doesn’t work.

I’d be ever so grateful if someone would let me know what’s wrong with this code.

If IsNull (Forms!FrmLiveApplicantView!FrmForwardAddView.Form!ForwardAddID) Then
Me.CmdOpenFrmSmallView.Visible = True
Else
Me. CmdOpenFrmSmallView.Visible = False
End If

Many thanks in advance
 
Just a shot, is ForwardAddID a Null dataType?

Is it an autonumber, or does it have a default value?
 
It's an autonumber. If that posses a problem I could point to different field
 
I think there's going to be some challenges trying to establish whether the subform contains records through accessing a control. I think I'd rather suggest using the recordcount property of the subforms recordset. This might also pose some challenges, though I can't remember what it might be;-)

[tt]If Forms!FrmLiveApplicantView!FrmForwardAddView.Form.recordsetclone.recordcount=0 Then[/tt]

Should be able to shorten it to

[tt]If Me!FrmForwardAddView.Form.recordsetclone.recordcount=0 Then[/tt]

Or as a "one liner":

[tt]Me.CmdOpenFrmSmallView.Visible = _
(Me!FrmForwardAddView.Form.recordsetclone.recordcount=0)[/tt]

Roy-Vidar
 
Many thanks Roy I'll Give it a bash n get back to you.
 
I take my hat off to you Roy. Works like a dream, just what I needed.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top