notinlist open form

deekras

Registered User.
Local time
Today, 14:12
Joined
Jun 14, 2000
Messages
169
i have a combobox which must be filled with one of the records in the list. if it is not on the list i want to open a form (pop-up or otherwise) for the user to put in information. (this form is already created and has a subform where the data will be added. this form can also be used without being accessed from the main menu - the coding has to be good for both ways in which it will be opened.)

1. i want that form to open up with the newdata already in one of the fields.

2. when the user clicks the ok button, i want that information to be in the combobox list.


thanks for your help.
 
if your subform is a bound control you need also information about the joined field. So I assume an unbound subform control in the following code
Code:
If MsgBox("Do you wan't to create a new record for " & NewData & "?", vbYesNo) = vbYes Then
  Response = acDataErrContinue
  DoCmd.OpenForm "frmMainform"
  With Forms!frmMainform!sfrControl
    .Setfocus
    DoCmd.GoToRecord ,,acNewRec
    .Form!YourControlToFill = NewData
  End With
Else
    Response = acDataErrContinue
    Me!cboYourCombobox.Undo
End If
'----------
' In the Close event of the main form you need something like
'----------
With Forms!YourCallingForm!cboYourCombobox 
  .Value = Me!sfrControl.Form!YourControlToFill
  .Requery
End With
 

Users who are viewing this thread

Back
Top Bottom