I have a code for a pop-up box that appears when a product is not in the list allowing you to add a product and requery. I can't seem to get it to work. Here it is:
Private Sub ProductID_NotInList(NewData As String, Response As Integer)
Private Sub ProductID_NotInList(NewData As String, Response As Integer)
Dim NewProduct As Integer, Title As String, MsgDialog As Integer
Dim MsgText As String
Const MB_YESNO = 4
Const MB_ICONEXCLAMATION = 48
Const MB_DEFBUTTON1 = 0, IDYES = 6, IDNO = 7
Const CLR_WHITE = 16777215
Const NORMAL = 1
If IsNull([ProductID]) Then
Title = "Product Not in List"
MsgDialog = MB_YESNO + MB_ICONEXCLAMATION + MB_DEFBUTTON1
NewProduct = MsgBox("Do you want to add a new product?", MsgDialog, Title)
If NewProduct = IDYES Then
DoCmd DoMenuItem A_FORMBAR, A_EDIT, A_UNDOFIELD
[ProductName] = NewData
[ProductID].SetFocus
MsgBox "Enter the new Product"
Response = DATA_ERRCONTINUE
End If
Else
MsgText = "To modify this product, edit"
MsgText = MsgText & "the product in the field"
MsgText = MsgText & "below. To add a new product, choose"
MsgText = MsgText & "Undo Record from the Records menu and"
MsgText = MsgText & "then type the new product name in the"
MsgText = MsgText & "ProductID combo box."
MsgBox MsgText
DoCmd DoMenuItem, A_FORMBAR, A_EDIT, A_UNDOFIELD
Response = DATA_ERRCONTINUE
End If
End Sub
End Sub
On the line that reads: DoCmd DoMenuItem A_FORMBAR, A_EDIT, A_UNDOFIELD, I keep getting a compile error: expected end of statement on A_FORMBAR. Does anyone know how to fix this?
Sincerely,
RdeanH
Private Sub ProductID_NotInList(NewData As String, Response As Integer)
Private Sub ProductID_NotInList(NewData As String, Response As Integer)
Dim NewProduct As Integer, Title As String, MsgDialog As Integer
Dim MsgText As String
Const MB_YESNO = 4
Const MB_ICONEXCLAMATION = 48
Const MB_DEFBUTTON1 = 0, IDYES = 6, IDNO = 7
Const CLR_WHITE = 16777215
Const NORMAL = 1
If IsNull([ProductID]) Then
Title = "Product Not in List"
MsgDialog = MB_YESNO + MB_ICONEXCLAMATION + MB_DEFBUTTON1
NewProduct = MsgBox("Do you want to add a new product?", MsgDialog, Title)
If NewProduct = IDYES Then
DoCmd DoMenuItem A_FORMBAR, A_EDIT, A_UNDOFIELD
[ProductName] = NewData
[ProductID].SetFocus
MsgBox "Enter the new Product"
Response = DATA_ERRCONTINUE
End If
Else
MsgText = "To modify this product, edit"
MsgText = MsgText & "the product in the field"
MsgText = MsgText & "below. To add a new product, choose"
MsgText = MsgText & "Undo Record from the Records menu and"
MsgText = MsgText & "then type the new product name in the"
MsgText = MsgText & "ProductID combo box."
MsgBox MsgText
DoCmd DoMenuItem, A_FORMBAR, A_EDIT, A_UNDOFIELD
Response = DATA_ERRCONTINUE
End If
End Sub
End Sub
On the line that reads: DoCmd DoMenuItem A_FORMBAR, A_EDIT, A_UNDOFIELD, I keep getting a compile error: expected end of statement on A_FORMBAR. Does anyone know how to fix this?
Sincerely,
RdeanH