Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

New Record

Posted on 2013-01-01
5
Medium Priority
?
423 Views
Last Modified: 2013-01-01
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
Comment
Question by:DatabaseDek
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 29

Expert Comment

by:IrogSinta
ID: 38734413
Use the form's OnCurrent event instead:
If Me.NewRecord = True Then Combo29.Requery

Open in new window

0
 
LVL 48

Assisted Solution

by:Dale Fye
Dale Fye earned 400 total points
ID: 38734416
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
 
LVL 29

Accepted Solution

by:
IrogSinta earned 1600 total points
ID: 38734423
You could also use the form's AfterInsert event for this:
Private Sub Form_AfterInsert()
    Combo29.Requery
End Sub

Open in new window

0
 

Author Closing Comment

by:DatabaseDek
ID: 38734460
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
 
LVL 29

Expert Comment

by:IrogSinta
ID: 38734479
AfterInsert fires when a new record is added. Not when traversing records.
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question