How to Open form as Dialog and then goto new record

XelaIrodavlas

Registered User.
Local time
Today, 10:41
Joined
Oct 26, 2012
Messages
175
Hello,

Apologies as I'm sure this will have been asked before but I couldn't find anything on the search.

I want to open a form as dialog to prevent users from going into anything else until they close the new form.

However, I also need to move this form to a new record when it opens.

Code looks like this:
Code:
DoCmd.OpenForm "ApprovalReviews", , , "SupplierID = " & Me!SupplierID, acFormAdd, acDialog 'Dialog to prevent write conflict.
 '####Opening as dialog is preventing the below from running until after the blighter has been closed.... which causes more errors because the form is no longer open.
Forms!ApprovalReviews!sApprovalReviews2.SetFocus
DoCmd.GoToRecord , , acNewRec

Anyone have any suggestions for a workaround?

Thanks All,
A
 
you add code to ApprovalReviews form's Load Event:

private sub form_load()
DoCmd.GotoRecord,, acNewRec
[sApprovalReviews2].setfocus
end sub
 
If you'll only ever use the form to enter data, you can set its DataEntry and AllowAdditions properties to Yes, which you can do through the GUI - no VBA needed.
 
you add code to ApprovalReviews form's Load Event:

private sub form_load()
DoCmd.GotoRecord,, acNewRec
[sApprovalReviews2].setfocus
end sub
I think you may have meant that the other way around(?) but thank you it works!

Code:
Private Sub Form_Load()
Me!sApprovalReviews2.SetFocus
DoCmd.GoToRecord , , acNewRec
End Sub
 

Users who are viewing this thread

Back
Top Bottom