how to show / hide duplicate button if a field is not null (1 Viewer)

akika

Registered User.
Local time
Today, 10:23
Joined
Aug 7, 2018
Messages
102
hi,

I've created a duplicate record button via the button wizard
Command Button Wizard > Record Operation > Duplicate Record button

How can i amend the button to show when field 'date_input' is not null
hide when date_input is null ??
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 01:23
Joined
May 7, 2009
Messages
19,169
use the Current Event of the Form:

Private Sub Form_Current()
Me.button.Visible = (IsNull(Me.Date_Input))
End Sub
 

isladogs

MVP / VIP
Local time
Today, 17:23
Joined
Jan 14, 2017
Messages
18,186
If it's a single form, add code similar to this in the form current event

Code:
Private Sub Form_Current()
If IsNull(Me.DateField) Then
     Me.CommandButton.Visible = False
Else
     Me.CommandButton.Visible = True
End If
End Sub

Change names as appropriate.
This won't work if it's a continuous form

EDIT arnel beat me to it
 

akika

Registered User.
Local time
Today, 10:23
Joined
Aug 7, 2018
Messages
102
hi,

Ive a continous form with a button 'Open this record' and added attached macros. when click on btn its opening the record.

BUT At end of the form there's a new record which is null.
when select the null ID getting error 295.

Any idea?
Or is it possible to hide that record & btn if all fields & ID is null??
 

Attachments

  • open_select_record.PNG
    open_select_record.PNG
    10 KB · Views: 24

Gasman

Enthusiastic Amateur
Local time
Today, 17:23
Joined
Sep 21, 2011
Messages
14,044
Shouldn't that be

Code:
Private Sub Form_Current()
Me.button.Visible = NOT IsNull(Me.Date_Input)
End Sub
???

use the Current Event of the Form:

Private Sub Form_Current()
Me.button.Visible = (IsNull(Me.Date_Input))
End Sub
 

Users who are viewing this thread

Top Bottom