Solved

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

Posted on 2014-04-29
5
914 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
[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
  • 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 38

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 38

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

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

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

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

626 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