M
Maarten
I've got this annoying thing where the reference to formfields are not
recognised in the VBA module if I refer to them by their name only. I
need to include the reference to the form. Is there a workaround,
would save me a lot of typing?
Example:
I've got a form (frm_AAA) with two text fields str_Greet and Result.
Apart from the coding in the object area of the form I created a
separate module to keep things clear. In this module there a sub which
calculates the color of the field Result (Calculation)
The code I in the object area:
Private Sub str_Greet_AfterUpdate()
Calculation
End Sub
And the module needs to be coded as follow:
Sub Calculation()
If str_Greet = Hello Then frm_AAA.Resultaat.BackColor = RBG(0,255,0)
Else If str_Greet = Cheers Then frm_AAA.Resultaat.BackColor =
RGB(255,0,0)
Else: MsgBox("Sorry, I can't hear you")
End If
End Sub
While I rather type:
Sub Calculation()
If str_Greet = Hello Then Resultaat.BackColor = RBG(0,255,0)
Else If str_Greet = Cheers Then Resultaat.BackColor = RGB(255,0,0)
Else: MsgBox("DSorry, I can't hear you")
End If
End Sub
Althoug the difference is minimal for this code, it definately makes
sense on 500+ lines of code.
Any help welcome, thanks.
Maarten
recognised in the VBA module if I refer to them by their name only. I
need to include the reference to the form. Is there a workaround,
would save me a lot of typing?
Example:
I've got a form (frm_AAA) with two text fields str_Greet and Result.
Apart from the coding in the object area of the form I created a
separate module to keep things clear. In this module there a sub which
calculates the color of the field Result (Calculation)
The code I in the object area:
Private Sub str_Greet_AfterUpdate()
Calculation
End Sub
And the module needs to be coded as follow:
Sub Calculation()
If str_Greet = Hello Then frm_AAA.Resultaat.BackColor = RBG(0,255,0)
Else If str_Greet = Cheers Then frm_AAA.Resultaat.BackColor =
RGB(255,0,0)
Else: MsgBox("Sorry, I can't hear you")
End If
End Sub
While I rather type:
Sub Calculation()
If str_Greet = Hello Then Resultaat.BackColor = RBG(0,255,0)
Else If str_Greet = Cheers Then Resultaat.BackColor = RGB(255,0,0)
Else: MsgBox("DSorry, I can't hear you")
End If
End Sub
Althoug the difference is minimal for this code, it definately makes
sense on 500+ lines of code.
Any help welcome, thanks.
Maarten