John thomas
Registered User.
- Local time
- Today, 07:15
- Joined
- Sep 4, 2012
- Messages
- 206
Hi All
This is my first try with VBA
and it will not work Help Please
In my program i have acombo box to select products .The idear is if the product is not in the list the code should put up a message box and ask do you want to add product .If the answer is yes it should open the products orders form to allow entry
However it puts up yhe following eror code
Compile error Label not in list and highlightsthe last line of code in blue
ption Compare Datab
Option Explicit
Private Sub ProCombo_GotFocus()
ProCombo.Requery
End Sub
Private Sub ProCombo_NotInList(NewData As String, Response As Integer)
On Error GoTo Err_ProCombo_NotInList
Dim intAnswer As Integer
intAnswer = MsgBox("Would you like to add this value to the list?", vbYesNo, vbQuestion)
If intAnswer = vbYes Then
DoCmd.RunCommand acCmdUndo
DoCmd.OpenForm "frmProducts", acNormal, , , acFormAdd, acDialog
Response = acDataErrAdded
Else
Response = acDataErrContinue
End If
Exit_ProComboNotInList:
Exit Sub
Err_ProCombo_NotInList:
MsgBox Err.Description
Resume Exit_ProCombo_NotInList:
End Sub
This is my first try with VBA
and it will not work Help Please
In my program i have acombo box to select products .The idear is if the product is not in the list the code should put up a message box and ask do you want to add product .If the answer is yes it should open the products orders form to allow entry
However it puts up yhe following eror code
Compile error Label not in list and highlightsthe last line of code in blue
ption Compare Datab
Option Explicit
Private Sub ProCombo_GotFocus()
ProCombo.Requery
End Sub
Private Sub ProCombo_NotInList(NewData As String, Response As Integer)
On Error GoTo Err_ProCombo_NotInList
Dim intAnswer As Integer
intAnswer = MsgBox("Would you like to add this value to the list?", vbYesNo, vbQuestion)
If intAnswer = vbYes Then
DoCmd.RunCommand acCmdUndo
DoCmd.OpenForm "frmProducts", acNormal, , , acFormAdd, acDialog
Response = acDataErrAdded
Else
Response = acDataErrContinue
End If
Exit_ProComboNotInList:
Exit Sub
Err_ProCombo_NotInList:
MsgBox Err.Description
Resume Exit_ProCombo_NotInList:
End Sub