G
Guest
Hi all,
I got a code for my command button to open different forms depending on
values of different fields. Luckily it works all right, but i suspect there
could be another solution here (like, may be, "select case" or smth else?)
instead of such a long code... Does anybody have any suggestions?
Private Sub Command0_Click()
On Error GoTo Err_Command0_Click
Dim stDocName As String
Dim stLinkCriteria As String
If [BA-176-USD_G] > 0 Then
stDocName = "BA-176-Received"
Else
End If
If [BA-176-USD_G] <= 0 Then
stDocName = "BA-176-Spent"
Else
End If
If [BA-324-VND_G] > 0 Then
stDocName = "BA-324-Received"
Else
End If
If [BA-324-VND_G] <= 0 Then
stDocName = "BA-324-Spent"
Else
End If
If [BA-305-VND_G] > 0 Then
stDocName = "BA-305-Received"
Else
End If
If [BA-305-VND_G] <= 0 Then
stDocName = "BA-305-Spent"
Else
End If
If [BA-351-USD_G] > 0 Then
stDocName = "BA-351-Received"
Else
End If
If ([BA-351-USD_G] <= 0) Then
stDocName = "BA-351-Spent"
Else
End If
If [Cash-VND] > 0 Then
stDocName = "Cash Received"
Else
End If
If [Cash-VND] <= 0 Then
stDocName = "Cash Spent"
Else
End If
stLinkCriteria = "[ID]=" & Me!ID1
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_Command0_Click:
Exit Sub
Err_Command0_Click:
MsgBox Err.Description
Resume Exit_Command0_Click
End Sub
Thank you.
Lana
I got a code for my command button to open different forms depending on
values of different fields. Luckily it works all right, but i suspect there
could be another solution here (like, may be, "select case" or smth else?)
instead of such a long code... Does anybody have any suggestions?
Private Sub Command0_Click()
On Error GoTo Err_Command0_Click
Dim stDocName As String
Dim stLinkCriteria As String
If [BA-176-USD_G] > 0 Then
stDocName = "BA-176-Received"
Else
End If
If [BA-176-USD_G] <= 0 Then
stDocName = "BA-176-Spent"
Else
End If
If [BA-324-VND_G] > 0 Then
stDocName = "BA-324-Received"
Else
End If
If [BA-324-VND_G] <= 0 Then
stDocName = "BA-324-Spent"
Else
End If
If [BA-305-VND_G] > 0 Then
stDocName = "BA-305-Received"
Else
End If
If [BA-305-VND_G] <= 0 Then
stDocName = "BA-305-Spent"
Else
End If
If [BA-351-USD_G] > 0 Then
stDocName = "BA-351-Received"
Else
End If
If ([BA-351-USD_G] <= 0) Then
stDocName = "BA-351-Spent"
Else
End If
If [Cash-VND] > 0 Then
stDocName = "Cash Received"
Else
End If
If [Cash-VND] <= 0 Then
stDocName = "Cash Spent"
Else
End If
stLinkCriteria = "[ID]=" & Me!ID1
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_Command0_Click:
Exit Sub
Err_Command0_Click:
MsgBox Err.Description
Resume Exit_Command0_Click
End Sub
Thank you.
Lana