moving to a record that was just created

G

Guest

I am replacing the following command:

Docmd.GoToRecord,, acNewRecord

with some underlying logic to take place whenever a new record is created.

It all works fine except-- now I want the form to be at that most record
(the new record that it just finished making)

In the cmdNewRecord button I have the following code...
but the last command seems to be ignored:

createNewRecord (see function below - but this works perfectly)
docmd.GoToRecord,,acLast (this doesn't work)

=====CreateNewRecord=== for reference below
With rsOffice
.AddNew
!DocID = currentDocID
!ProviderType = 2
!MVDocID = Form_DocEntry.Doctors_FedIDNo
.Update
.Bookmark = rsOffice.LastModified
End With

NewOfficeID = rsOffice!OfficeID

If MsgBox("Use this provider's billing address as the location
address for this office?", vbYesNo + vbQuestion, "Use Billing address for
this location?") = vbYes Then

With rsOfficeAddress
.AddNew
!OfficeID = NewOfficeID
If Not IsNull(Form_DocEntry.Street1) Then !StreetLine1 =
Form_DocEntry.Street1
If Not IsNull(Form_DocEntry.Street2) Then !StreetLine2 =
Form_DocEntry.Street2
If Not IsNull(Form_DocEntry.City) Then !City =
Form_DocEntry.City
If Not IsNull(Form_DocEntry.State) Then !State =
Form_DocEntry.State
If Not IsNull(Form_DocEntry.Zip) Then !Zip =
Form_DocEntry.Zip
.Update
.Bookmark = rsOfficeAddress.LastModified
End With
 
M

Mark

Instead of "docmd.GoToRecord,,acLast " , assuming NewOfficeID is an integer
value returned by your function [is the function called NewOfficeID?), try
something like this (bear in mind this is air code):

Dim lngOfficeID as Long
Dim strFind as String
lngOfficeID=NewOfficeID()
strFind="[OfficeID]=" & lngOfficeID
Me.Recordset.FindFirst strFind
 

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

Similar Threads


Top