Blazer Saga
Registered User.
- Local time
- Today, 11:54
- Joined
- Jan 22, 2007
- Messages
- 12
I am new to using modules so please bear with me, I am trying to write a module with some commonly used procedures in my forms to save on time coding.
This is just one of them but the rest will all be similar so it should suffice to help me.
The module code is:
Option Compare Database
Function EnableField(ByRef Control As TextBox, ByRef Lable As Label, ByVal Enabled As Boolean)
Dim ColorGrey As Long
ColorGrey = RGB(130, 130, 130)
If Enabled = True Then
Lable.ForeColor = ColorGrey
End If
End Function
And the form code that calls it is:
Option Compare Database
Private Sub TxtInvoiceAmount_AfterUpdate()
If (Not IsNull(Me.TxtShippingQuoted.Value)) And (Not IsNull(Me.TxtInvoiceAmount.Value)) Then
Me.TxtCommissionAmount.Value = (Me.TxtShippingQuoted.Value - Me.TxtInvoiceAmount.Value)
EnableField(Me.TxtCommissionAmount, Me.LblCommissionAmount, True)
End If
End Sub
The code is far from complete (will have it changing fore and background colors on both objects, as well as possibly locking or unlocking the control.) I am doing this to allow more control over the look of the form then simply setting the control as Enabled or Disabled.
The problem I have is a compile error where it expects an "=" after the function call in the form.
I have done this by with the "ByRef" Values with declared and undeclared types. With Function or Sub declarations in the function definition for the module I get the "=" error.
Any clues as how to make this simply take in the references and change some of their vales on the form?
Am I going about this in the completely wrong way?
Any help is greatly appreciated.
This is just one of them but the rest will all be similar so it should suffice to help me.
The module code is:
Option Compare Database
Function EnableField(ByRef Control As TextBox, ByRef Lable As Label, ByVal Enabled As Boolean)
Dim ColorGrey As Long
ColorGrey = RGB(130, 130, 130)
If Enabled = True Then
Lable.ForeColor = ColorGrey
End If
End Function
And the form code that calls it is:
Option Compare Database
Private Sub TxtInvoiceAmount_AfterUpdate()
If (Not IsNull(Me.TxtShippingQuoted.Value)) And (Not IsNull(Me.TxtInvoiceAmount.Value)) Then
Me.TxtCommissionAmount.Value = (Me.TxtShippingQuoted.Value - Me.TxtInvoiceAmount.Value)
EnableField(Me.TxtCommissionAmount, Me.LblCommissionAmount, True)
End If
End Sub
The code is far from complete (will have it changing fore and background colors on both objects, as well as possibly locking or unlocking the control.) I am doing this to allow more control over the look of the form then simply setting the control as Enabled or Disabled.
The problem I have is a compile error where it expects an "=" after the function call in the form.
I have done this by with the "ByRef" Values with declared and undeclared types. With Function or Sub declarations in the function definition for the module I get the "=" error.
Any clues as how to make this simply take in the references and change some of their vales on the form?
Am I going about this in the completely wrong way?
Any help is greatly appreciated.