Create new record and move to it in the form load

G

Guest

I may be doing this wrong, but there it goes. I open my main input form from
a new issue form, with an openargs of 1. Here is the form load code on the
main input form:

Private Sub Form_Load()

If Me.OpenArgs = 1 Then
Call createnew_issue
Me.Issue_Reference_Number = Forms!frmnewissue_setup.Text5
Me.division = Forms!frmnewissue_setup.Combo3
Me.Year = Forms!frmnewissue_setup.Text9
Me.Combo206 = Forms!frmnewissue_setup.Combo11
'MsgBox "We have prepopulated some fields, but you can change them
if you need to."
Me.Detail.Visible = True
DoCmd.GoToRecord , , acLast
DoCmd.Close acForm, "frmnewissue_setup"
'Me.OpenArgs = 0
End If
DoCmd.Maximize

End Sub

and createnew_issue sub is:

Public Sub createnew_issue()

DoCmd.GoToRecord , , acNewRec
[Issue Entry Date] = Now()

End Sub

So I am trying to make sure the user sees the new record they created on the
first form. The form currently opens on the first record in the database,
but if I click on the goto last button I created, I can see the new record
(hence why I tried the docmd.goto last above).

Do I have to move records after the Form Load has completed?
Thanks
 
B

banem2

I may be doing this wrong, but there it goes. I open my main input form from
a new issue form, with an openargs of 1. Here is the form load code on the
main input form:

Private Sub Form_Load()

If Me.OpenArgs = 1 Then
Call createnew_issue
Me.Issue_Reference_Number = Forms!frmnewissue_setup.Text5
Me.division = Forms!frmnewissue_setup.Combo3
Me.Year = Forms!frmnewissue_setup.Text9
Me.Combo206 = Forms!frmnewissue_setup.Combo11
'MsgBox "We have prepopulated some fields, but you can change them
if you need to."
Me.Detail.Visible = True
DoCmd.GoToRecord , , acLast
DoCmd.Close acForm, "frmnewissue_setup"
'Me.OpenArgs = 0
End If
DoCmd.Maximize

End Sub

and createnew_issue sub is:

Public Sub createnew_issue()

DoCmd.GoToRecord , , acNewRec
[Issue Entry Date] = Now()

End Sub

So I am trying to make sure the user sees the new record they created on the
first form. The form currently opens on the first record in the database,
but if I click on the goto last button I created, I can see the new record
(hence why I tried the docmd.goto last above).

Do I have to move records after the Form Load has completed?
Thanks

Hi,

It appears you move to new record (call to sub), write there Issue
Entry Data and other data, and then move to last record (Form Load)? I
think you need to requery data:

Me.Detail.Visible = True
Me.Requery
DoCmd.GoToRecord , , acLast

Let me know if this helps.

Regards,
Branislav Mihaljev
 
G

Guest

I don't think I need a requery, since the form is based directly on the
table. I only put in the docmd.goto last in the form load since that is how
I got to the record once I got focus of the form.
--
Yours Fictionally, Biggles


I may be doing this wrong, but there it goes. I open my main input form from
a new issue form, with an openargs of 1. Here is the form load code on the
main input form:

Private Sub Form_Load()

If Me.OpenArgs = 1 Then
Call createnew_issue
Me.Issue_Reference_Number = Forms!frmnewissue_setup.Text5
Me.division = Forms!frmnewissue_setup.Combo3
Me.Year = Forms!frmnewissue_setup.Text9
Me.Combo206 = Forms!frmnewissue_setup.Combo11
'MsgBox "We have prepopulated some fields, but you can change them
if you need to."
Me.Detail.Visible = True
DoCmd.GoToRecord , , acLast
DoCmd.Close acForm, "frmnewissue_setup"
'Me.OpenArgs = 0
End If
DoCmd.Maximize

End Sub

and createnew_issue sub is:

Public Sub createnew_issue()

DoCmd.GoToRecord , , acNewRec
[Issue Entry Date] = Now()

End Sub

So I am trying to make sure the user sees the new record they created on the
first form. The form currently opens on the first record in the database,
but if I click on the goto last button I created, I can see the new record
(hence why I tried the docmd.goto last above).

Do I have to move records after the Form Load has completed?
Thanks

Hi,

It appears you move to new record (call to sub), write there Issue
Entry Data and other data, and then move to last record (Form Load)? I
think you need to requery data:

Me.Detail.Visible = True
Me.Requery
DoCmd.GoToRecord , , acLast

Let me know if this helps.

Regards,
Branislav Mihaljev
 

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