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!

check to see if a record already exists? 1

Status
Not open for further replies.
Jan 27, 2003
35
GB
why is it you solve one problem and another one rears its ugly head?

here it is.....

I have a form which contains personal data and relates to table 1.

on the form there is a button to open a new form containing emegency contact numbers, this form links to a second table.

the forms are linked by personID.

In order for me to add a new person and insert their data in to table 1 before opening the second form, i used a save record bit of code on the onclick of the button i.e.

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

i then open the form and link them in the same procedure.
( i had to do this as a record had to exist in personal details table in order for a corresponding record to exist in the emergency details table, 2 tables linked by a 1 to 1 relationship, naughty i know ) this works great........

The problem i have occurs when i want to view the emergency details of a person that already exists; as the message 'the command or action "SaveRecord" isnt available now' and i dont progress to the form containing the emergency details.

how do i get around this. I am thinking of using an if statement to check to see if a record exists: i.e.

if record exists continue
else SaveRecord blah blah blah

but not sure what the code would be or how to do it

Please help?!?!?!
 
try something like
if me.dirty then docmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
or try
if me.newrecord then docmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

what i dont understand why access in not letting you save a old record
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top