Merge 2 codes (1 Viewer)

Gismo

Registered User.
Local time
Tomorrow, 00:48
Joined
Jun 12, 2017
Messages
1,085
Hi all,

I am trying to merge the below 2 codes, somehow not working, is my continuation correct?

Private Sub Form_Current()
If Forms![Menu]![StatusRegFilter]![OpenCSOrdersFromMenuRegistration].Form.RecordsetClone.RecordCount = 0 Then
Forms![Menu]![StatusRegFilter]![OpenCSOrdersFromMenuRegistration].Form.Visible = False
Else
Forms![Menu]![StatusRegFilter]![OpenCSOrdersFromMenuRegistration].Form.Visible = True
End If

'If IsNull(Me.Registration) Then
'Me.OpenCSOrdersFromMenuRegistration.Visible = False
'Me.StatusBtn.Visible = False
'Else
'Me.OpenCSOrdersFromMenuRegistration.Visible = True
'Me.StatusBtn.Visible = True
'End If

my try
If Forms![Menu]![StatusRegFilter]![OpenCSOrdersFromMenuRegistration].Form.RecordsetClone.RecordCount = 0 And IsNull(Me.Registration) Then
Forms![Menu]![StatusRegFilter]![OpenCSOrdersFromMenuRegistration].Form.Visible = False
Me.StatusBtn.Visible = False
Else
Forms![Menu]![StatusRegFilter]![OpenCSOrdersFromMenuRegistration].Form.Visible = True
Me.StatusBtn.Visible = True
End If
 

cheekybuddha

AWF VIP
Local time
Today, 22:48
Joined
Jul 21, 2014
Messages
1,012
It looks like Me.StatusBtn is on the subform.

Which form are you running this code from? The main form's Current event? The subform's Current event?

Describe your forms/subforms.

Is [StatusRegFilter] also a subform?
 

Gismo

Registered User.
Local time
Tomorrow, 00:48
Joined
Jun 12, 2017
Messages
1,085
It looks like Me.StatusBtn is on the subform.

Which form are you running this code from? The main form's Current event? The subform's Current event?

Describe your forms/subforms.

Is [StatusRegFilter] also a subform?
The main frrm is the Menu form
Subform is StatusRegFilter
The button is within the StatusRegFilter subform

Code is running from the subform StatusRegFilter
 

cheekybuddha

AWF VIP
Local time
Today, 22:48
Joined
Jul 21, 2014
Messages
1,012
What is OpenCSOrdersFromMenuRegistration ?

A subform of StatusRegFilter subform ?
 

cheekybuddha

AWF VIP
Local time
Today, 22:48
Joined
Jul 21, 2014
Messages
1,012
Try it like this:
Code:
Private Sub Form_Current()

  Dim blVisible As Boolean

  With Me
    blVisible = .OpenCSOrdersFromMenuRegistration.Form.RecordCount = 0 AND IsNull(.Registration)
    .OpenCSOrdersFromMenuRegistration.Visible = blVisible
    .StatusBtn.Visible = blVisible
  End With

End Sub
 

Users who are viewing this thread

Top Bottom