NotInList Question

lumpy2497

Registered User.
Local time
Today, 15:16
Joined
Jun 10, 2003
Messages
17
Hi Everyone!!! Hoping someone can help me with this.

I maintain a database that contains information about apartments that our business rents for clients. Included in the tables are those for landlord info (name, address, etc.) named "landlord", apartment info (address, accounts, etc.) named "apartment", and one for payments made (address, amount, etc.) names "payments".

I have a form setup that enables me to add/update apartment info based on a table named "apartment". Included in this table is the identifier (setup as a combo box) that connects me to the landlord information in a table called "landlord".

What I would like to do is create a code, probably associated with -NotInList- event, that will open the form setup for the landlord info WHEN the landlord identifier is not included in the "landlord" table so that I can add the landlord's information.

Many thanks to those that can help!

Leeann.... :)
 
Basically, are you saying that if the Landlords name is not in the ComboBox list, you then want to go to the landlord screen and add it?

Col
 
That's it!

Exactly!!

Leeann... :)
 
Questions...

When I cut and paste and run it, I have an error message that comes up dealing with:

' database and recordset object variables
Dim db As DAO.Database
Dim rs As DAO.Recordset

I gather the sense of the code, but what would I use to replace "DAO.Database" and "DAO.Recordset"??

Many thanks!!!

Leeann... :)
 
So you should use the ADO version not the DAO.
 
Still Not Working

For some reason, it's still not working...

Here's what I have changed, and the error message that get says that it's looking for a delete, update, etc.

The name of the table to update is: Landlord Information
The field that gets updated in table is : Landlord_ID
The name of the combo box is: LandlordID

If MsgBox(Message1 & NL & Message2, vbQuestion + vbYesNo, Title) = vbYes Then
' open a connection to the connection object
Set cn = CurrentProject.Connection
' initialise the recordset object
Set rs = New ADODB.Recordset
' using the recordset object
With rs
.Open "Landlord Information", cn, adOpenStatic, adLockPessimistic ' open it
.AddNew ' prepare to add a new record
.Fields([Landlord_ID]) = NewData ' add unfound data into field
.Update "Landlord Information" ' update the table
.Close ' close the recordset connection
End With
Response = acDataErrAdded ' confirm record added
Else
Me.LandlordID.Undo ' clear the entry in the combobox
Response = acDataErrContinue ' confirm the record is not allowed
End If



Once again... Thanks for all the help!

Leeann... :)
 

Users who are viewing this thread

Back
Top Bottom