Solved

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

Posted on 2014-04-29
5
875 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 35

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 35

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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

832 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