visible if field is not NULL

carlchapman

Registered User.
Local time
Today, 11:35
Joined
Jul 25, 2006
Messages
29
Hiya, i fixed my problem with using a openform button to display related results. But i have found a new problem. On the subform with a parent table, the command buttons are displayed for all sub records, this includs adding a [auto number] / auto record for new records. Is there a way so only if records exsist to have the record and command button visible (if not NULL) and in the sub form where a new record is displayed to be removed / made visible false. ?
 
carlchapman said:
Hiya, i fixed my problem with using a openform button to display related results. But i have found a new problem. On the subform with a parent table, the command buttons are displayed for all sub records, this includs adding a [auto number] / auto record for new records. Is there a way so only if records exsist to have the record and command button visible (if not NULL) and in the sub form where a new record is displayed to be removed / made visible false. ?

The short answer is no. In a continuous form each object like a button is not really a seperate object or even a copy it is the same button displayed for each record.

How can you tell?

Add this to your subform.

Code:
Private Sub Form_Current()

If Me.NewRecord = True Then

Me.Command4.Visible = False 'replace command4 with the name of your command button
else
        Me.Command4.Visible = True


End If

End Sub

Click on the new record. Pop. All the buttons disappear. Click on a complete record and they all come back.
Seems obvious now as your referencing just that one button "Me.Command4." but it's a real PITA.

Rather than locking or hiding the button - which as i've said will affect all the buttons - i think this would be better.
on the click event of the button
Code:
If Me.NewRecord = True Then

msgbox "Please enter details",vbinformation,"Missing data required"

exit sub
End If

'rest of your code that opens the pop_up form here.

HTH

K
 
Last edited:

Users who are viewing this thread

Back
Top Bottom