If field has a particular in subform then disable/enable certain buttons

ravness

Registered User.
Local time
Today, 19:01
Joined
Aug 12, 2008
Messages
22
Hi guys

I've got a form with a subform, which has 4 records below:

ID - sStatus - sAvailableStatus
1 - Holiday - Unavailable
2 - Unavailable - Unavailable
3 - Confirmed - Chargeable
4 - Provisional - Chargeable

Then in the main form there are two buttons

cmdExcludeProvisional runs a script which deletes the word "Chargeable" from the provisional field.

cmdIncludeProvisional adds the word "Chargeable" to the provisional field.

After this both commands then runs a lot of processing then refreshes the subform to show the change.

Ideally, I only want one of these buttons to be enabled at one particular point.

If the provisional field is blank i want cmdExcludeProvisional to be disabled and if provisional field has "Chargeable" then I want cmdIncludeProvisional to be disabled.

Any ideas on this guys?
 
In the subform's On Current Event put
Code:
With Me.Parent
If Me!YourFieldName = "Chargeable" Then
   .cmdIncludeProvisional.Enabled = True
   .cmdExcludeProvisional.Enabled = False
Else
   .cmdIncludeProvisional.Enabled = False
   .cmdExcludeProvisional.Enabled = True
End If
 
almost perfect

problem is its only one of the fields im interested in which is the provisional one


all others could say "Chargeable" but this one could be blank or something

I want it so if that particular record is "Chargeable" then disable/enable buttons.

Thanks for the try though...
 
I tried this doesnt work thoguh and overly complicated

Private Sub Form_Current()
Dim db As Database
Dim tblStatusRules As Object
Dim fldEnumerator As Object
Dim fldColumns As Object
Set db = CurrentDb
Set tblStatusRules = db.OpenRecordset("tblStatusRules")
Set fldColumns = tblStatusRules.Fields
' Scan the records from beginning
While Not tblStatusRules.EOF
' Check the current column
For Each fldEnumerator In tblStatusRules.Fields
' If the column is named sStatus
If fldEnumerator.Name = "sStatus" Then
' If the title of the current record is "Provisional"
If fldEnumerator.Value = "Provisional" Then
If fldEnumerator.Name = "sAvailableStatus" Then
If fldEnumerator.Value = "Chargeable" Then
cmdIncludeProvisional.Enabled = False
Else
cmdIncludeProvisional.Enabled = True
End If
End If
End If
End If
Next
tblStatusRules.MoveNext
Wend
End Sub
 

Users who are viewing this thread

Back
Top Bottom