S
spiderq
I have set up a simple form which has a textbox to get criteria to run
an update query, I have put a subform on it which displays the stock
table and used a macro to requery the table(created from a select
query) and show that the updated stock in the table ( using continuous
forms).
I want to change the background colour of the stock field if the the
value has changed.
I am not very good with VBA so please bear with me!
I have created a module called StockLevel which I think will hold the
initial value of the Stock field as a Global variable before I run
the update query( so available to the rest of my code after the
requery)
**********************************************************************
Option Compare Database
Public currentLevel As Integer
**********************************************************************
I have then added this code to the subform:
*************************************************************************
Private Sub Form_Current()
currentLevel = [Stock].Value
End Sub
Private Sub Form_AfterUpdate()
Dim bWhite As Long
Dim bRed As Long
bRed = RGB(255, 0, 0)
bWhite = RGB(255, 255, 255)
If [Stock].Value > StockLevel Then
[Stock].BackColor = bRed
Else
[Stock].BackColor = bWhite
End If
End Sub
**************************************************************
What have I done wrong here? The rest of my simple process works fine.
an update query, I have put a subform on it which displays the stock
table and used a macro to requery the table(created from a select
query) and show that the updated stock in the table ( using continuous
forms).
I want to change the background colour of the stock field if the the
value has changed.
I am not very good with VBA so please bear with me!
I have created a module called StockLevel which I think will hold the
initial value of the Stock field as a Global variable before I run
the update query( so available to the rest of my code after the
requery)
**********************************************************************
Option Compare Database
Public currentLevel As Integer
**********************************************************************
I have then added this code to the subform:
*************************************************************************
Private Sub Form_Current()
currentLevel = [Stock].Value
End Sub
Private Sub Form_AfterUpdate()
Dim bWhite As Long
Dim bRed As Long
bRed = RGB(255, 0, 0)
bWhite = RGB(255, 255, 255)
If [Stock].Value > StockLevel Then
[Stock].BackColor = bRed
Else
[Stock].BackColor = bWhite
End If
End Sub
**************************************************************
What have I done wrong here? The rest of my simple process works fine.