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

determining if the records exists before trying to update

Status
Not open for further replies.

ScubaStevo

Programmer
May 4, 2002
132
AU
How can I determine if a record exists before trying to update it? Is there a query I can run for this or do I need to do this within a form?

Thanks, Steve
 
Just looking at this from a relational point of view ie sets, you can ask SQL to update specific rows. It then selects the rows that match your criteria and carries out the update. You don't need to know whether the rows exist or not.

It's not clear what you're trying to achieve but if you're trying to update something in the database without knowing whether it already there, you have a life-cycle design problem not a programming problem.

Can you expand on what you are trying to do?

 
It was just for a warning message for the user. It works fine whether the record exists or not, but with the warning messages turned off the user has no idea if the update was successful. It is assumed to be successful but if they made a typo and entered a record that didnt exist, they would still think the update was successful even though no update was made.
That was why it would be helpful to see if the record existed first so the user could be stopped, unless there is a better way to do this??
 
Access provides you with a very neat facility - the dynaset. If you run a query it allows you to update the underlying table just by changing the data on the screen. So what you do is supply some means for the user to select the record they want. A simple way is to design a form with an unbounded text box, then drop a command button onto the form and the wizard will set things up so another form (which obviously you must have built beforehand), showing all the records and their data, only displays the record matching your input. Using this scheme it is immediately obvious if the user has made a mistake - they will get a blank form. You can also set the form to accept or refuse inserts.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top