Verify that record Exists

G

GakDev

I need to see if a record exists when I load a form. If
it doesn't , I need to insert the information into a
table before the form is disolayed and the record
referenced should be the new record. I have to associate
a parent id to tie the record to the parent table. Any
help would be appreciated.
 
I

Ivar Svendsen

Sub Form_Load()

Form.RecordsetClone.FindFirst "KEYFIELD=WhatYouWantToFind"
If Form.RecordsetClone.NoMatch Then
' The record was not found. Create a new record
if not newrecord then docmd.runcommand
accmdrecordsgotonew
' Initialize the new record
[Field] = Value
else
' Go to the record you wanted
Bookmark = Form.RecordsetClone.Bookmark
end if

end sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top