passing variable between sub procedure

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all,

In my project, there is a repeat procedure.
In each procedure, I get a value and with the value I will get the
description.
To do that, I coded a simple procedure as following

Private Sub Form_Current()
Dim ConKey As Single

If Me.COND1 = "No" Then
ConKey = 1
ElseIf Me.COND1 = "Yes" Then
If IsNull(Me.COND3) Then
ConKey = 2
ElseIf Me.COND3 = "Yes" Then
ConKey = 3
ElseIf Me.COND3 = "No" Then
If Me.COND4 = "No" Then
If Me.COND5 = "No" Then
ConKey = 6
ElseIf Me.COND5 = "Yes" Then
ConKey = 5
End If
ElseIf Me.COND4 = "Yes" Then
ConKey = 4
End If
End If
End If

Call controlstat(ConKey)
End Sub

Private Sub controlstat(Key As Single)
Dim recstat1 As String
Dim recstat2 As String
Dim recstat3 As String
Dim recstat4 As String
Dim recstat5 As String
Dim recstat6 As String

recstat1 = "AAA"
recstat2 = "BBB"
recstat3 = "CCC"
recstat4 = "DDD"
recstat5 = "EEE"
recstat6 = "FFF"
'the value fo recstat1-6 is not real value.

Me.statusKey = Key

If Key = 1 Then
Me.STATUS = recstat1
ElseIf Key = 2 Then
Me.STATUS = recstat2
ElseIf Key = 3 Then
Me.STATUS = recstat3
ElseIf Key = 4 Then
Me.STATUS = recstat4
ElseIf Key = 5 Then
Me.STATUS = recstat5
ElseIf Key = 6 Then
Me.STATUS = recstat6
End If

Me.statusKey.Requery
End Sub

My project does not transfer ConKey value to controlstat procedure.
I do not know what is wrong in this coding.
Please help me.

Thank you so much.
 
Are you sure that ConKey has a value when you call the subroutine? Put a
breakpoint on the line
Call controlstat(ConKey)

and verify that it's actually being assigned a value.
 
Back
Top