Not in list - Open form

  • Thread starter Thread starter SAC
  • Start date Start date
S

SAC

I'm using an estimating form with a combo box for inventory.

I want to open the inventory form if there's not an inventory item in the
combo box of the estimating form, enter the inventory info, close the form
and continue with the estimating form.

Since I have entered the description in the combo box of the estimating form
I would like this to be automatically entered in the description control on
the inventory form. And I'd like the control for Category to have
ELECTRICAL already in it when the form opens.

Also, how do I pause the below code until the inventory form is closed?

Do I use the Open_Args some way?

Private Sub txtInvenKey_NotInList(NewData As String, Response As Integer)
Response = acDataErrContinue

Dim intAnswer As Integer
Dim dbs As DAO.Database, rst As DAO.Recordset
Dim strOldValue As String
Dim strName As String
Dim varCost As Variant

Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("tblInventory", dbOpenDynaset) 'Open the
recordset for the combobox table

intAnswer = MsgBox("Add " & NewData & " to Inventory?", vbQuestion +
vbYesNo) 'Caption of ComboBox

If intAnswer = vbYes Then

'********** Opens inventory form **************
DoCmd.OpenForm "frmInventory", acNormal

Response = acDataErrAdded ' Requery the combo box list.
Exit Sub
Else
Me.Undo
Response = acDataErrContinue ' Require the user to select
' an existing item
End If

End Sub



THANKS!
 
You can't stop the code, but you can conditionally avoid it completing. As
to passing the desctription to the form you want to open, use the OpenArgs
and assign it the value in NewData. It will contain whatever was entered.
Then in the form you are opening, assing the value to the control in the
Load event. For the ELECTRICAL part, make it the Default Value of the
control it will be in.
 
Thanks!
Klatuu said:
You can't stop the code, but you can conditionally avoid it completing. As
to passing the desctription to the form you want to open, use the OpenArgs
and assign it the value in NewData. It will contain whatever was entered.
Then in the form you are opening, assing the value to the control in the
Load event. For the ELECTRICAL part, make it the Default Value of the
control it will be in.
 
Back
Top