Doozer1979
Registered User.
- Local time
- Today, 19:03
- Joined
- Jul 4, 2007
- Messages
- 32
Hello,
I have the following piece of code, which is causing me a bit of grief at the moment. How do i pass a variable (labelName) to be used as a control name?
For reference, i have labels that will become visible when the following code is executed by clicking on the corresponding control for that label.
Hope that explains it right
Many thanks!
I have the following piece of code, which is causing me a bit of grief at the moment. How do i pass a variable (labelName) to be used as a control name?
For reference, i have labels that will become visible when the following code is executed by clicking on the corresponding control for that label.
Hope that explains it right
Code:
Public Sub insertNPTMonths(tableName As String, fieldName As String, labelName As Label)
Dim max As Integer
max = InputBox("What is the integer of the Month", vbYesNo, "Month Number")
Dim x As Integer
For x = 1 To 6
DoCmd.RunSQL "Update " & tableName & " set " & tableName & ".Month_Num = " & x & " WHERE datepart('m',[" & tableName & "." & fieldName & "]) = " & (((max + 1) - x) Mod 12) & ""
Next
If MsgBox("Operation Complete.", vbOKOnly + vbInformation) = vbOK Then
Me.labelName.Visible = True
End If
Many thanks!