Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with Dlookup, to find record or add record?

Status
Not open for further replies.

AccessDevJunior

Programmer
Apr 14, 2004
81
GB
hya,

i have a main form called 'frm_ID', its record source is a table (tbl_ID) with only one field 'ID Number'.
The main form has a subform called 'frm_IDSub', its record source is a table (tbl_IDSub) with a field 'ID Number' and several other fields.
the two tables have a one to many relationship.

I would like to place and unbound text box and a command button on the main form. I want the user to be able to enter the Id number in the unbound text box then click the command button.
On clicking the command button i would like the code to lookup in 'tbl_Id' to see if the ID Number exists, then if it does find that record, if not add a new record.

if anyone could help me put this code together it would be a great help
 
Why not using a combobox with a NotInList event procedure ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
ive never used this procedure before, ive changed my text box to a combo box could you help me with the code please
 
While in VBE press the F2 key to launch the Object browser, do a search for notinlist and then press the F1 key to get get a good code example.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
im getting an error msg saying "the text you have entered isnt an item in the list"???
ive had a little play with but im still not sure what to do
 
Try....

Private Sub cboControlName_OnNotInList(Response as Integer)
code to add new record
Response = DataErrAdded
End Sub



Randy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top