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

x
?
Solved

Me.NewRecord not being recognized

Posted on 2011-09-13
6
Medium Priority
?
284 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
ID: 36529804
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 1600 total points
ID: 36529841
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
ID: 36530020
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
Independent Software Vendors: 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!

 

Author Comment

by:yddadsjd95
ID: 36530293
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
ID: 36530382
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
ID: 36530420
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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

916 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