Go To Record

D

dale fye

Sorry, accidentally hit send

A couple of issues.

1. you don't need or want to reference Me when referring
to the parent form, although you could, I prefer the
technique shown below.

2. you need to make sure you do something if the
findfirst method fails to find the value you are looking
for.

Watch out for the line wrap on the strCriteria line

HTH
Dale

*****************************

Dim strCriteria as string
Dim rs as recordset

strCriteria = "[Project Number] = " & Forms("Plan
Status").[ProjectNumber]
set rs = me.recordsetclone
rs.findfirst strCriteria

if rs.nomatch then
docmd.gotorecord ,,,acNew
me.ProjectNumber = Forms("Plan Status").ProjectNumber
else
me.bookmark = rs.bookmark
endif
rs.close
set rs = nothing
 
G

Guest

Hey Dale,
Thanks for the info thus far! I made the following adjustments (I had a big
no-no and had a couple of fields from a table with spaces):

Dim strCriteria As String
Dim rs As Recordset

strCriteria = "[Project_Number] = " & Forms("Plan Status").[ProjectNumber]
Set rs = Me.RecordsetClone
rs.FindFirst strCriteria

If rs.NoMatch Then
DoCmd.GoToRecord , , acNewRec
Me.Project_Number = Forms("Plan Status").ProjectNumber
Else
Me.Bookmark = rs.Bookmark
End If

rs.Close
Set rs = Nothing

It does exactly what I want it to with a new record, except it inserts a new
record every time, despite the fact that there is a match. Any ideas?
Thanks in advance.

Neil
 

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