run macro if a fileds font colour is green

goodhead

Registered User.
Local time
Today, 03:59
Joined
Feb 18, 2013
Messages
37
I have conditional formatting on a field. green and red
Is it possible to click a button and it looks at the fields font colour and if its green it runs a macro.

I not sure if I asking to much of access. Hopefully an expert here might guide me.

Thanks

Dan
 
You have a condition which has turned it green in conditional formatting.

So you will have a criteria for it being green so you can use the same criteria to determine whether or not to run a macro.
 
You have a condition which has turned it green in conditional formatting.

So you will have a criteria for it being green so you can use the same criteria to determine whether or not to run a macro.

Not sure how to tell it then to run a macro.

In criteria at moment its basically comparing 2 numbers in a query. if they match goes green.

[Qry-Reg1]![Expr1]=[Qry-Reg1]![Key]

I then need to run mco-licence

Are you sure it can do this?
 
I also tried having a macro using if statement. but that just comes up with error saying cant find the query yet I was able to add to expression with its search tool.

thought that would be simple.


Not sure how to tell it then to run a macro.

In criteria at moment its basically comparing 2 numbers in a query. if they match goes green.

[Qry-Reg1]![Expr1]=[Qry-Reg1]![Key]

I then need to run mco-licence

Are you sure it can do this?
 
Unfortunately I don't use macros but in code you would use

If [Qry-Reg1]![Expr1]=[Qry-Reg1]![Key] then docmd.openquery "mco-licence"

As to which event you would put it against, that depends on your form - if it is a single form view then I would suggest the oncurrent event
 
it is a single form.
this is what I added.

Private Sub Command9_Click()
If [Tbl-Owner]![Key] = [Tbl-Owner]![AutoGenKey] Then DoCmd.OpenQuery "McoLicence"
End Sub

I get run time error 2465.
cant find the field '|1 referred to in your expression.


this is on a button on the form. on click






Unfortunately I don't use macros but in code you would use

If [Qry-Reg1]![Expr1]=[Qry-Reg1]![Key] then docmd.openquery "mco-licence"

As to which event you would put it against, that depends on your form - if it is a single form view then I would suggest the oncurrent event
 
cant find the field '|1 referred to in your expression.
This implies there is something in your query called |1
 
Code:
If Me![Key] = Me![AutoGenKey] Then DoCmd.OpenQuery "McoLicence"

The references are to the controls (or fields in the form's recordset if there is no control by the name). The Me refers to the current class object, ie the form, and should always be included in code.
 

Users who are viewing this thread

Back
Top Bottom