Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 427
  • Last Modified:

New Record

I am using the following to ascertain if a record is new and if so run a requery

Private Sub Combo29_On_Enter()
If Me.NewRecord = True Then
    DoCmd.Echo False
        Combo29.Requery
    DoCmd.Echo True
End If
end sub

Its for when a new record has been entered onto a form a requery updates the combo box with the new record details.

Doesn't work
0
DatabaseDek
Asked:
DatabaseDek
  • 3
2 Solutions
 
IrogSintaCommented:
Use the form's OnCurrent event instead:
If Me.NewRecord = True Then Combo29.Requery

Open in new window

0
 
Dale FyeCommented:
I generally use the Form_Current event to test if you are on a new record

Private Sub Form_Current

    If Me.NewRecord = True Then Combo29.Requery

End If

And I almost never use the Echo method to prevent screen updates.  If I do, I ensure that I have an error handler on that code segment to ensure that if an error occurs, I can set Echo = True in the error handler.
0
 
IrogSintaCommented:
You could also use the form's AfterInsert event for this:
Private Sub Form_AfterInsert()
    Combo29.Requery
End Sub

Open in new window

0
 
DatabaseDekAuthor Commented:
Thank you both<br /><br />I tried my code in the OnCurrent but it did not work because if a user enters a new record and then moves to another existing record the oncurrent will not know it's a new record and will not fire. So I use the On enter because it only updates the required combo. (There are 4 on this form all used to find existing records.<br /><br />The After Insert would appear to be the answer I will try that.<br /><br />Yep that's got it<br /><br />Can you tell me does after insert fire after each field/control insertion or only when moving to another record
0
 
IrogSintaCommented:
AfterInsert fires when a new record is added. Not when traversing records.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now