E
EAB1977
Hi All,
I have a form to where a user enters information into a combo box. If
the data in the combo box does not match what is in the combo box, my
NotInList event is triggered. WIthin this code, I have a option to
take the user to the item, if they want to. If they click Yes, the
NotInList gets triggered again. I do not want this to happen.
How do I prevent this from happening?
Option Compare Database
Dim cnn As ADODB.Connection
Private Sub cboPlateNumber_NotInList(NewData As String, Response As
Integer)
Dim strSQL As String, rsInfo As New ADODB.Recordset, msg As Integer
Dim db As DAO.Database, rsStandard As New ADODB.Recordset
' -- Check to see if the plate number is already entered into the
database.
' -- EB - 7/2/2010
Stop
Response = acDataErrContinue
Set cnn = CurrentProject.Connection
strSQL = "SELECT StandardType FROM tblStandard WHERE PlateNumber =
'" & NewData & "'"
rsStandard.Open strSQL, cnn, adOpenKeyset, adLockOptimistic
If Not rsStandard.BOF And Not rsStandard.EOF Then
strSQL = "SELECT LLBPRD, LLDSCP FROM
dbo_vwProductPlateAttribute WHERE " _
& "LLUPRD = '" & NewData & "'"
rsInfo.Open strSQL, cnn, adOpenKeyset, adLockOptimistic
msg = MsgBox("The print standard " & rsInfo!LLBPRD & " - " &
rsInfo!LLDSCP & " is already entered into" _
& " the database." & Chr(13) & Chr(13) & "Would you like
to go to the print standard?", _
vbYesNo)
Select Case msg
Case 6 'Yes
Select Case rsStandard!StandardType
Case 1
intFormStatus = 2 'Edit Mode
blnNewStandard = False
DoCmd.OpenForm "frmFoamCupStandard", acNormal
Case 2
intFormStatus = 2 'Edit Mode
blnNewStandard = False
DoCmd.OpenForm "frmFusionCupStandard",
acNormal
End Select
DoCmd.Close acForm, Form.Name, acSaveNo
Case 7 'No
'Do nothing, the user clicked No
End Select
Else
' -- State to the user why the print is not in the list
strSQL = "SELECT LLBPRD, LLDSCP, LLPSTS FROM
dbo_vwProductPlateAttribute WHERE " _
& "LLUPRD = '" & NewData & "'"
rsInfo.Open strSQL, cnn, adOpenKeyset, adLockOptimistic
Select Case rsInfo!LLPSTS
Case "C"
MsgBox "The print standard " & rsInfo!LLBPRD & " - " &
rsInfo!LLDSCP & " has been" _
& " cancelled accoring to the AS/400.", vbOKOnly,
"Cancelled Print"
Case "I"
MsgBox "The print standard " & rsInfo!LLBPRD & " - " &
rsInfo!LLDSCP & " has been" _
& " inactivated accoring to the AS/400.",
vbOKOnly, "Inactivated Print"
Case "P"
MsgBox "The print standard " & rsInfo!LLBPRD & " - " &
rsInfo!LLDSCP & " is" _
& " pending accoring to the AS/400.", vbOKOnly,
"Pending Print"
Case "E"
MsgBox "The print standard " & rsInfo!LLBPRD & " - " &
rsInfo!LLDSCP & " has been" _
& " classified as experimental accoring to the AS/
400.", vbOKOnly, "Experimental Print"
Case "R"
MsgBox "The print standard " & rsInfo!LLBPRD & " - " &
rsInfo!LLDSCP & " has been" _
& " replaced accoring to the AS/400.", vbOKOnly,
"Replaced"
Case "S", "W"
MsgBox "The print standard " & rsInfo!LLBPRD & " - " &
rsInfo!LLDSCP & "has not been" _
& " approved for use.", vbOKOnly, "Unapproved
Print"
Case Else
MsgBox "The print standard does not exist.", vbOKOnly,
"No Plate Found"
End Select
End If
rsStandard.Close
rsInfo.Close
End Sub
I have a form to where a user enters information into a combo box. If
the data in the combo box does not match what is in the combo box, my
NotInList event is triggered. WIthin this code, I have a option to
take the user to the item, if they want to. If they click Yes, the
NotInList gets triggered again. I do not want this to happen.
How do I prevent this from happening?
Option Compare Database
Dim cnn As ADODB.Connection
Private Sub cboPlateNumber_NotInList(NewData As String, Response As
Integer)
Dim strSQL As String, rsInfo As New ADODB.Recordset, msg As Integer
Dim db As DAO.Database, rsStandard As New ADODB.Recordset
' -- Check to see if the plate number is already entered into the
database.
' -- EB - 7/2/2010
Stop
Response = acDataErrContinue
Set cnn = CurrentProject.Connection
strSQL = "SELECT StandardType FROM tblStandard WHERE PlateNumber =
'" & NewData & "'"
rsStandard.Open strSQL, cnn, adOpenKeyset, adLockOptimistic
If Not rsStandard.BOF And Not rsStandard.EOF Then
strSQL = "SELECT LLBPRD, LLDSCP FROM
dbo_vwProductPlateAttribute WHERE " _
& "LLUPRD = '" & NewData & "'"
rsInfo.Open strSQL, cnn, adOpenKeyset, adLockOptimistic
msg = MsgBox("The print standard " & rsInfo!LLBPRD & " - " &
rsInfo!LLDSCP & " is already entered into" _
& " the database." & Chr(13) & Chr(13) & "Would you like
to go to the print standard?", _
vbYesNo)
Select Case msg
Case 6 'Yes
Select Case rsStandard!StandardType
Case 1
intFormStatus = 2 'Edit Mode
blnNewStandard = False
DoCmd.OpenForm "frmFoamCupStandard", acNormal
Case 2
intFormStatus = 2 'Edit Mode
blnNewStandard = False
DoCmd.OpenForm "frmFusionCupStandard",
acNormal
End Select
DoCmd.Close acForm, Form.Name, acSaveNo
Case 7 'No
'Do nothing, the user clicked No
End Select
Else
' -- State to the user why the print is not in the list
strSQL = "SELECT LLBPRD, LLDSCP, LLPSTS FROM
dbo_vwProductPlateAttribute WHERE " _
& "LLUPRD = '" & NewData & "'"
rsInfo.Open strSQL, cnn, adOpenKeyset, adLockOptimistic
Select Case rsInfo!LLPSTS
Case "C"
MsgBox "The print standard " & rsInfo!LLBPRD & " - " &
rsInfo!LLDSCP & " has been" _
& " cancelled accoring to the AS/400.", vbOKOnly,
"Cancelled Print"
Case "I"
MsgBox "The print standard " & rsInfo!LLBPRD & " - " &
rsInfo!LLDSCP & " has been" _
& " inactivated accoring to the AS/400.",
vbOKOnly, "Inactivated Print"
Case "P"
MsgBox "The print standard " & rsInfo!LLBPRD & " - " &
rsInfo!LLDSCP & " is" _
& " pending accoring to the AS/400.", vbOKOnly,
"Pending Print"
Case "E"
MsgBox "The print standard " & rsInfo!LLBPRD & " - " &
rsInfo!LLDSCP & " has been" _
& " classified as experimental accoring to the AS/
400.", vbOKOnly, "Experimental Print"
Case "R"
MsgBox "The print standard " & rsInfo!LLBPRD & " - " &
rsInfo!LLDSCP & " has been" _
& " replaced accoring to the AS/400.", vbOKOnly,
"Replaced"
Case "S", "W"
MsgBox "The print standard " & rsInfo!LLBPRD & " - " &
rsInfo!LLDSCP & "has not been" _
& " approved for use.", vbOKOnly, "Unapproved
Print"
Case Else
MsgBox "The print standard does not exist.", vbOKOnly,
"No Plate Found"
End Select
End If
rsStandard.Close
rsInfo.Close
End Sub