Pop-up Form

W

Wayne

I know this can be done, but I just can not figure it out or find it
anywhere. Any help??

Problem:
I have a combo box, it the item is not in the list, then I would like to be
able to dbl_click ... open a pop-up form ... enter the information ...
return to the main form ... have the new information available to the user.

I know how to open the pop-up form (docmd.openform "frmpopup" , , ,
acformadd, acdialog)

I tried the docmd.requery. I believe it worked, but the new information is
not selected. Also, I seem to be getting an extra 'blank' record from the
pop-up.

Thanks,
Wayne
 
J

jahoobob via AccessMonster.com

Here is code from Dev Avish at the AccessWeb that I put in the NotInList
property of the combo:

Private Sub TruckCompany_NotInList(NewData As String, Response As Integer)
'************ Code Start **********
' This code was originally written by Dev Ashish.
' It is not to be altered or distributed,
' except as part of an application.
' You are free to use it in any application,
' provided the copyright notice is left unchanged.
'
' Code Courtesy of
' Dev Ashish
'
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strMsg As String

strMsg = "'" & NewData & "' is not an available Trucking Company " &
vbCrLf & vbCrLf
strMsg = strMsg & "Do you want to add this company to the current list?"
strMsg = strMsg & vbCrLf & vbCrLf & "Click Yes to add or No to re-type it.
"

If MsgBox(strMsg, vbQuestion + vbYesNo, "Add new company?") = vbNo Then
Response = acDataErrContinue
Else
Set db = CurrentDb
Set rs = db.OpenRecordset("tblTruckingCompanies", dbOpenDynaset)
On Error Resume Next
rs.AddNew
rs!Company = NewData
rs.Update

If Err Then
MsgBox "An error occurred. Please try again."
Response = acDataErrContinue
Else
Response = acDataErrAdded
End If

End If

rs.Close
Set rs = Nothing
Set db = Nothing
'End Sub
'*********** Code End **************


End Sub

You need to set the Limit To List property of the combo to Yes. It doesn't
do what you want via a popup but it does what you want. Of course you will
need to cahnge the combobox and table names.
 
W

Wayne

Thanks,

One other question, what if I wanted to add more then just the truckcompany
name. Say, I wanted to have the address and a contact name or such as that
so that later I could use the address in a different form/report?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top