J
JK
Access 2003
In a subform (Workorder Vendor) I want to allow the user to double click
ProductID to add a new Vendor Part. The vendor parts in the combo box of the
subform are dependant on a combo box on the main form (Workorders.) So,
before a user can add a new Vendor Part by double clicking the productID on
the subform, they must select a Vendor on the main form.
For the most part, the following code works. I'm just having trouble with
the setfocus part of it - for some reason it doesn't work.
The error says I can't move the focus to that field - any idea why?
Private Sub ProductID_DblClick(Cancel As Integer)
If IsNull(Forms![Workorders].Form![txtSupplierID] Or
[Forms]![Workorders].Form![txtSupplierID] = "") Then
MsgBox "You must select a vendor before adding a Vendor Part.",
vbOKOnly
Forms![Workorders].Form![txtSupplierID].SetFocus
End If
Exit Sub
If vbYes = MsgBox("Do you want to add a new Vendor Part?", vbYesNo +
vbQuestion + vbDefaultButton2, gstrAppTitle) Then
' Open the add a Vendor Part form
DoCmd.OpenForm "Vendor Parts Entry Form", DataMode:=acFormAdd,
WindowMode:=acDialog
' Requery the combo on return in case a row actually added
Me.ProductID.Requery
' Expose the new list of Vendor Parts
Me.ProductID.Dropdown
End If
End Sub
In a subform (Workorder Vendor) I want to allow the user to double click
ProductID to add a new Vendor Part. The vendor parts in the combo box of the
subform are dependant on a combo box on the main form (Workorders.) So,
before a user can add a new Vendor Part by double clicking the productID on
the subform, they must select a Vendor on the main form.
For the most part, the following code works. I'm just having trouble with
the setfocus part of it - for some reason it doesn't work.
The error says I can't move the focus to that field - any idea why?
Private Sub ProductID_DblClick(Cancel As Integer)
If IsNull(Forms![Workorders].Form![txtSupplierID] Or
[Forms]![Workorders].Form![txtSupplierID] = "") Then
MsgBox "You must select a vendor before adding a Vendor Part.",
vbOKOnly
Forms![Workorders].Form![txtSupplierID].SetFocus
End If
Exit Sub
If vbYes = MsgBox("Do you want to add a new Vendor Part?", vbYesNo +
vbQuestion + vbDefaultButton2, gstrAppTitle) Then
' Open the add a Vendor Part form
DoCmd.OpenForm "Vendor Parts Entry Form", DataMode:=acFormAdd,
WindowMode:=acDialog
' Requery the combo on return in case a row actually added
Me.ProductID.Requery
' Expose the new list of Vendor Parts
Me.ProductID.Dropdown
End If
End Sub