Add a Record to Table via New Entry in a Text

  • Thread starter Thread starter theshadowknz
  • Start date Start date
T

theshadowknz

I believe I understand the Notinlist to add a record to a
table using a combo box; but how would the same apply to a
text box that gets its data from a table, example-Vendor
name coming from Vendor table; want any new vendor entry
to come up with "Want to Add This Vendor?" message and
then load the Vendor Form --
 
I suggest you use a combobox in this situation. It has the advantages of
autocomplete, and also offers a list for selection, both of which can speed
data entry and avoid errors. You certainly should not store the vendor name
in a related record unless VendorName is the primary key in the Vendors
table.

However, if you feel you must use a plain textbox, then perform a DLookup
(or DCount) in the textbox's BeforeUpdate event procedure. For example:
If DCount("*", "tblVendors", "VendorName=""" _
& txtVendorName & """") = 0 Then
If MsgBox( "Add new vendor?", vbYesNo ) = vbYes Then
' add new vendor to table
Else
Cancel = True
End If
End If
 
Back
Top