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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open new or existing record 2

Status
Not open for further replies.

Acipenser

Technical User
Oct 15, 2001
39
0
0
US
Hello all,

I am having a few problems with my database. I have a form (frmCane2) in which the user enters information then clicks a button (butLabNotes) to open another form (frmLabnotes)to enter more information. At the bottom of frmLabnotes is a button (butClose) to close the form and return to frmCane2.

What I want butLabNotes to do is to check to see if a record for the sample (entered in frmCane2) already exists. If it does then I want the frmLabNotes to open with that record showing, otherwise I want the form to open to a new record.

This is so that if someone is entering data into frmLabNotes, closes the form, and realizes they forgot to enter something or entered something wrong, then they can just click the button to edit the information. I do not want frmLabNotes to save a new record each time the button is pressed. Only when one did not exist previously.

Thanks,
Bill
 
could you not base the (frmLabNotes) on a query, and use the sample entered into the (frmCane2) field as the criteria for the query. Then use an Iif statement in the query to say that if no record matches, open the form (frmLabNotes) where the identifying field has a Null value.

I'm certainly no expert, so I may be barking up the wrong tree here - but I got it to work on a similar thing I have done. If anyone else knows another way, I could certainly use it too.

Hope it helps!!

Dongled
 
Dongled,

Thanks for the help. I assume I am going to have to write this querry in visual basic, and I have not done that yet. Could you give me some code for that based on the above criteria?

If I can just make a normal query (say using the wizard) and base the form on it, how do I get it to open a new record if one does not exist?

Thanks,
Bill
 
Open your new form with a query that includes the record that would be a dulplicate. If not records, add the data. If records, change or peruse the data.

rollie@bwsys.net
 
Rolliee,

How do I check for no records, and then add a record?

Sorry, kind of new to this.

Thanks,
Bill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top