Solved

Me.NewRecord not being recognized

Posted on 2011-09-13
6
273 Views
Last Modified: 2012-05-12
I am attempting to open a repair order to create an estimate for a customer who is having his/her vehicle worked on. the following is a sketch of the form that creates the invoice:

1. There is a parent form that allows the user to enter DateIn, DateOut, MilesIn, Miles Out, etc
2. There is a subform that permits the user to enter the parts needed for the repair.
3. There is a subform that allows the user to identify the items that need repair - turn rotors, oil change, replace front brake pads, etc.
4. This subform has the customer contact data and vehicle information.

It appears to be item 4 above that is giving me the trouble. When a new record is created, I want frmJobSub (Item 4 above) to automatically load the customer contact info and vehicle info. See code below. The result that I am expecting is that when the user clicks the button that opens the new invoice/record, I am expecting the test for a new record to  be true and the program to execute the If-Then code, but it is not.

Although I am looking at a new record, could someone please assist me in determining why the new record is not being recognized by the  program?

Thanks in advance.

r/David

Private Sub Form_Current()

 If Me.NewRecord Then 'And Not IsNull(lngpvtCustomerID) Then
        lngpvtCustomerID = Forms!frmCustomerContactData.CustomerID
        'Look up the cust fields
        Me.lblFullName = DLookup("FirstName", "tblMasterCustomer", "CustomerID=" & lngpvtCustomerID & " ")
        'Save these entries
        DoCmd.RunCommand acCmdSaveRecord
        'Clear the variable
        lngpvtCustomerID = Null
    End If


End Sub

Open in new window

0
Comment
Question by:yddadsjd95
  • 3
  • 2
6 Comments
 

Author Comment

by:yddadsjd95
Comment Utility
Oh, I forgot to say that the DLookup function is only one of about a dozen lines of code that I need to put in the On Current event. I only placed one in there to test it. I'm trying to load some values into the new form when it opens.
0
 
LVL 61

Accepted Solution

by:
mbizup earned 400 total points
Comment Utility
Try populating the data in the desired fields from the event code that opens the form in stead of from the form itself.

ie:

  'Following your code that opens the form and goes to a new record...
Forms!YourFormName.lblFullName = DLookup("FirstName", "tblMasterCustomer", "CustomerID=" & me.CustomerID & " ")

 
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
Comment Utility
FWIW,

That code I posted presumed that the new record you were creating was on the same form as the form you are currently in...
...again, FWIW...

I am sure that mbizup can get you sorted...
0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 

Author Comment

by:yddadsjd95
Comment Utility
You are correct Jeff, Once I get over this hurdle, I'll be able to follow the code that you gave me...hopefully :-).

Thank you mbizup, I'm working on it, but after placing the code on the object that calls the estimate-form (btnRepairOrder), I get the following error:

Run-time Error '2448'.
You can't assign a value to this object.

If I understood you and Jeff correctly, I placed the DLookup function on the button that opens the estime-form (frmJob, with a subform frmJobSub), and not in  frmJobSub).

Thanks!
0
 

Author Closing Comment

by:yddadsjd95
Comment Utility
I forgot the code, but after viewing the error message and going back to the code, I figured out why the object could receive a value: because it was a label instead of a text box.

Thanks for the help.
0
 
LVL 61

Expert Comment

by:mbizup
Comment Utility
I was just about to submit a response, refreshed the screen and saw that you had worked this out.

Nice job!

I guess you figured out the "Caption" property for labels?
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

743 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now