Hide Command Button if Criteria is Met?

scouser

Registered User.
Local time
Today, 15:12
Joined
Nov 25, 2003
Messages
767
Hi Guys. I want to Display a command button on a form dependent on the value of another control.

I have a Main Form: frmSalesOrders and a Sub Form frmSalesOrderDetails

I have a command cmdSpecialInvoice on frmSalesOrders.
On Form Load I hide this.

However if the user selects a MakeID from frmSalesOrderDetails with an ID of 61 I want the button to be visible.

I attempted to put this on the After Update Event of control 'MakeID'

Code:
If Forms!frmSalesOrderDetails!MakeID = 61 Then
    Forms!frmSalesOrders!cmdSpecialInvoice.Visible = True
     End If

I got an error stating could not find frmSalesOrderDetails?

That aside is it possible to do what I want?

Note:
MakeId is a combo. Takes its value from qryMakes if tht makes a difference.

Any ideas?
Cheers,
Phil.
 
If me!MakeID = 61 Then
Forms!frmSalesOrders!cmdSpecialInvoice.Visible = True
End If

???
kh
 
Re-name MakeID to txtMakeID on the forms property sheet,

In the form CurrentEvent
If Me.txtMakeID = 61 Then
Me.cmdSpecialInvoice.Visible = True
Else
Me.cmdSpecialInvoice.Visible = False
End If

in the After Update of MakeID type

Call Form_Current or just Form_Current
 
Cheers Guys

Thanks guys, I will give your suggestions a whirl and post back.
Phil.
 
Combination

Thnaks guys. I used a combination of both:

Code:
Private Sub Form_Current()
Me.cboMakeID.Requery
Me.cboModelID.Requery

If Me!MakeID = 61 Or Me!MakeID = 62 Then
Forms!frmSalesOrders!cmdSpecialInvoice.Visible = True
Forms!frmSalesOrders!cmdSpecialInvoicePrint.Visible = True
Forms!frmSalesOrders!cmdPreviewInvoice.Visible = False
Forms!frmSalesOrders!cmdPrintInvoice.Visible = False
Else
Forms!frmSalesOrders!cmdSpecialInvoice.Visible = False
Forms!frmSalesOrders!cmdSpecialInvoicePrint.Visible = False
Forms!frmSalesOrders!cmdPreviewInvoice.Visible = True
Forms!frmSalesOrders!cmdPrintInvoice.Visible = True
End If

and then....
Code:
Private Sub cboMakeID_AfterUpdate()
Form_Current
    Me.cboModelID.Requery
      End Sub

Thanks Guys,
Phil.
 
Youi should not use Requery statements in the Form Current event
 
No Re-Query

Hi Rich. The on -current re-query was done by Pat for the cascading combo.
Works a treat so why do you say no?
Cheers,
Phil.
:confused:
 

Users who are viewing this thread

Back
Top Bottom