Solved

Me.NewRecord not being recognized

Posted on 2011-09-13
6
278 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
[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
  • 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
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 

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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

751 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