open form only when necessary

  • Thread starter Thread starter Scott
  • Start date Start date
S

Scott

I'm moving into new teretory by creating my most ambitious form yet. Perhaps
it'll be a piece of cake for you experts :)

If you've used Quicken and the Online Payee list then you'll be familiar
with what I'm trying to do. In Quicken, if you enter a payment and indicate
"Send" and then enter the Payee name, if the Payee doesn't yet exist then a
form opens up where you can enter the Payee name, address, account and
telephone number.

I want to do the same thing in my new Access form. On the parent form I want
to do a lookup on the customer id field [CUID]. If the customer hasn't been
entered in the Customer Master table yet then I'd like the option to open a
child form to create a new customer record.

Any suggestion on how I can do this or where I can read more about forms
like this?

Scott
 
Hi, Scott. Piece of cake. :)

The approach is:

- Open a data entry form (i.e., Data Entry property = Yes).
- Enter the new customer record.
- Close the data entry form, returning to the original.
- Requery the CustomerID combo box to include the new
record.

Search VBA Help for:

- OpenForm method
- DoCmd option (DoCmd.Close to close data input form)
- Requery method

HTH
Kevin Sprinkel
I want to do the same thing in my new Access form. On the
parent form I want to do a lookup on the customer id field
[CUID]. If the customer hasn't been entered in the
Customer Master table yet then I'd like the option to open
a child form to create a new customer record.
 
if you're looking up the customer id from a combo box in the form, here's
some *sample* code that may help you:

Private Sub MyComboBox_NotInList(NewData As String, _
Response As Integer)

If MsgBox("Do you want to add a new customer to the list?", _
vbDefaultButton1 + vbYesNo) = vbYes Then
strColor = NewData
'NOTE: the form that opens must be Single Form view, or
'Continuous Form view. It cannot be Datasheet View.
DoCmd.OpenForm "MyForm", , , , acFormAdd, _
acDialog
Response = acDataErrAdded
Else
Response = acDataErrContinue
Me!MyComboBox = Null
Me!MyComboBox.Dropdown
End If

substitute the correct names of your combo box and 'add customer' form in
place of "MyComboBox" and "MyForm", of course. when the user enters an ID
that doesn't exist, the code asks a new customer should be added. if the Yes
button is clicked, the add form opens and the code is suspended. when the
add form is closed, the code resumes, automatically requerying the combo box
to include the new customer id. if the No button is clicked, the entry in
the combobox is erased and the droplist opened, so the user can start fresh
in that control.

hth
 
Back
Top