J
jean.ulrich
Hi
I am using the following script to open different forms
Private Sub Commande288_Click()
Dim stDocName As String
Dim stLinkCriteria As String
If Left([NoItem], 4) = "34-0" Then
stDocName = "34-0"
stLinkCriteria = "[NoItem]=" & "'" & Me![NoItem] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
End If
If Left([NoItem], 4) = "41-0" Then
stDocName = "41-0"
stLinkCriteria = "[NoItem]=" & "'" & Me![NoItem] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
End If
If Left([NoItem], 4) = "41-1" Then
stDocName = "41-1"
stLinkCriteria = "[NoItem]=" & "'" & Me![NoItem] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
End If
If Left([NoItem], 4) = "51-0" Then
stDocName = "51-0"
stLinkCriteria = "[NoItem]=" & "'" & Me![NoItem] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
End If
End Sub
The question is "what can i use (different code) to produce the same
thing ?
Should I use select case statement and if the answer is yes, how should
I proceed
Also, I would like to add a message box for all items that don't have a
related form
msgbox "There is no form for this kind of item"
thanks
I am using the following script to open different forms
Private Sub Commande288_Click()
Dim stDocName As String
Dim stLinkCriteria As String
If Left([NoItem], 4) = "34-0" Then
stDocName = "34-0"
stLinkCriteria = "[NoItem]=" & "'" & Me![NoItem] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
End If
If Left([NoItem], 4) = "41-0" Then
stDocName = "41-0"
stLinkCriteria = "[NoItem]=" & "'" & Me![NoItem] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
End If
If Left([NoItem], 4) = "41-1" Then
stDocName = "41-1"
stLinkCriteria = "[NoItem]=" & "'" & Me![NoItem] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
End If
If Left([NoItem], 4) = "51-0" Then
stDocName = "51-0"
stLinkCriteria = "[NoItem]=" & "'" & Me![NoItem] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
End If
End Sub
The question is "what can i use (different code) to produce the same
thing ?
Should I use select case statement and if the answer is yes, how should
I proceed
Also, I would like to add a message box for all items that don't have a
related form
msgbox "There is no form for this kind of item"
thanks