Solved

Me.NewRecord not being recognized

Posted on 2011-09-13
6
276 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 400 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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 

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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

840 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