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!

how can i check if the record has not been saved 1

Status
Not open for further replies.

rene1000

IS-IT--Management
Apr 9, 2002
89
NL
I have created a form which contains a save button to save the current record. is it possible to check if the record has not been saved yet using VB code ?
 
Hi,

If you just want to check whether your record got saved or not, try using the code below ( I have assumed id to be the primary key ):

Private Sub CheckSave_Click()

Dim db as DAO.Database
Dim rs as DAO.Recordset

Set db=CurrentDB
Set rs=db.OpenRecordset("Select * from YourTable where id=" & Val(Me.txtId), dbOpenDynaset)

If rs.recordcount > 0 then
Msgbox "Saved Successfully"
Else
Msgbox "Record lost"
End If

rs.Close
db.Close

End Sub Hope it helps. Let me know what happens.
With regards,
PGK
 
Use the Dirty property, to see if the form has any pending changes which have still to be applied to the underlying recordsource. For example, a snippet of code behind a button might be:

if me.dirty then
'...your code
end if


Steve Lewy
Solutions Developer
steve@lewycomputing.com.au
(dont cut corners or you'll go round in circles)
 
Thankyou both very much for the replies. both options work but steve101s option is much easier.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top