Solved

Auto fill field on a 1st form when double-click a field on the 2nd form

Posted on 2014-04-29
5
861 Views
Last Modified: 2014-05-04
I have a form open which contains a command button that opens a 2nd form which is a continuous form.  The first form stays open.  When the user double-clicks on a records first field I want a field on the 1st field to fill with a value on the 2nd form's record.

My code of the double-click event of the records first field is:

Forms!subfrmEstParts.cboType = Me.txtPaperType

I'm getting an error:

Runtime error: 2465
Application-defined or object defined error

--Steve
0
Comment
Question by:SteveL13
  • 2
  • 2
5 Comments
 
LVL 8

Expert Comment

by:Ganapathi
ID: 40029628
See if this helps. I created a blank worksheet with 2 sheets named Sheet1 and Sheet2 and placed a Button on Sheet1. Added the below code to the Sheet1. Works fine.

Private Sub Submit_Click()
ThisWorkbook.Sheets(2).Range("A2").Value = "Test"
End Sub

Open in new window

0
 

Author Comment

by:SteveL13
ID: 40029636
This is a MS Access topic/question.
0
 
LVL 34

Expert Comment

by:PatHartman
ID: 40029748
If I can trust your naming convention, you are referring to a subform.  That means your reference needs to change to include the main form.

Forms!frmMainForm!subfrmEstParts.Form!cboType = Me.txtPaperType

Forms!
   mainform name   !  subform name   .Form!   control name
0
 

Author Comment

by:SteveL13
ID: 40029968
I changed the code to read:

    Forms!frmEstimate!subfrmEstParts.Form!cboType = Me.txtPaperType

But now I get an error indicating it can't file the field subfrmEstParts (which isn't even a field, it's the subform name)  ?????

So I added the line of code to open the subform:

    DoCmd.OpenForm "subfrmEstParts", acNormal, , , acFormAdd, acWindowNormal

    Forms!frmEstimate!subfrmEstParts.Form!cboType = Me.txtPaperType

And still get the error indicating it can't file the field subfrmEstParts


????
0
 
LVL 34

Accepted Solution

by:
PatHartman earned 500 total points
ID: 40030056
You can't open the subform directly.  ALSO - when you "push" something to a different form, that form MUST be open.  So the code won't work at all unless the form you are poking is actually open.  And the final warning is - you are poking the CURRENT record which may or may not be what you think it is.  This is a dangerous process plus, in a properly normalized schema you would not need to do this since a normalized schema does NOT contain duplicated data.

Check the Name property of the subform control.  It might be different from the name you are using.  When you reference the subform on the main form, you are actually referencing the control.  That's why the name you use is the Name property of the control.
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
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…
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…

895 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

13 Experts available now in Live!

Get 1:1 Help Now