Subform with Macro

I have a form (frm_BinDetails), within this form I have a subform
(frm_Cable). frm_Cable has a listbox (List23) which when the user
clicks on an entry the contents of the first column of that listbox
are displayed in a textbox (txt_ProcessID). The on click event of the
listbox runs a macro with the following code

Action = SetValue

Item = [Forms]![frm_Cable]![txt_ProcessID]

Expression = [Forms]![frm_Cable]![List23]

When I run the form frm_Cable on its own the macro works correctly but
when I try and run from frm_BinDetails then whenever I click on an
entry an error message appears saying that Access can't find the form
'frm_Cables' and then it displays my macro.

Any suggetions would be appreciated as to what I'm doing wrong (I've
already checked spellings and there all correct)

Thanks

0
Asif
5/10/2007 4:36:46 PM
access 16762 articles. 2 followers. Follow

4 Replies
1290 Views

Similar Articles

[PageSpeed] 18

I haven't done macros in years, except for AutoKeys, but it's clear that 
your problem is in the reference to the text box.

A Form embedded in a subform is not "Open" and, thus, not in the Forms 
Collection -- it is the Form property of the Subform Control.  But it's not 
clear to me whether "frm_Cable" is the name of your Subform Control or the 
Form embedded in that SubformControl.  The proper reference would be:

  Forms!frm_BinDetails!<nameofsubformcontrol>.Form!<nameofcontrol>

There isn't an Access Object called a "Subform" though we often use that 
verbal shortcut to talk about either the "Subform Control" or "Form embedded 
in a Subform Control" -- and, perhaps, that's why it can be confusing.

 Larry Linson
 Microsoft Access MVP

"Asif" <asifhashmani@hotmail.com> wrote

 > I have a form (frm_BinDetails), within this
 > form I have a subform (frm_Cable). frm_Cable
 > has a listbox (List23) which when the user
 > clicks on an entry the contents of the first
 > column of that listbox are displayed in a
 > textbox (txt_ProcessID). The on click event
 > of the listbox runs a macro with the
 > following code
 >
 > Action = SetValue
 >
 > Item = [Forms]![frm_Cable]![txt_ProcessID]
 >
 > Expression = [Forms]![frm_Cable]![List23]
 >
 > When I run the form frm_Cable on its own
 > the macro works correctly but when I try
 > and run from frm_BinDetails then whenever
 > I click on an entry an error message appears
 > saying that Access can't find the form
 > 'frm_Cables' and then it displays my macro.
 >
 > Any suggetions would be appreciated as to what I'm
 > doing wrong (I've already checked spellings and
 > there all correct)
>
> Thanks
> 


0
Larry
5/10/2007 8:30:19 PM
On 10 May 2007 09:36:46 -0700, Asif <asifhashmani@hotmail.com> wrote:

>I have a form (frm_BinDetails), within this form I have a subform
>(frm_Cable). frm_Cable has a listbox (List23) which when the user
>clicks on an entry the contents of the first column of that listbox
>are displayed in a textbox (txt_ProcessID). The on click event of the
>listbox runs a macro with the following code
>
>Action = SetValue
>
>Item = [Forms]![frm_Cable]![txt_ProcessID]
>
>Expression = [Forms]![frm_Cable]![List23]
>
>When I run the form frm_Cable on its own the macro works correctly but
>when I try and run from frm_BinDetails then whenever I click on an
>entry an error message appears saying that Access can't find the form
>'frm_Cables' and then it displays my macro.

If frm_Cable is being used as a Subform, it is *not* open in its own right,
and is not part of the Forms collection. You need to navigate to it via the
mainform:

[Forms]![frm_BinDetails]![frm_Cable].Form![txt_ProcessID]

Note that frm_Cable here is the Name property of *the Subform control* - by
default, this will be the same as the name of the Form within that control,
but it need not be.

             John W. Vinson [MVP]
0
John
5/10/2007 8:50:41 PM

Thanks guys, I've tried to made the modifications as per your
suggestions but unfortunately I'm still getting an error message

Item:- [Forms]![frm_BinDetails]![frm_Cable].[Form]![txt_ProcessID]

Expression:- [Forms]![frm_BinDetails]![frm_Cable].[Form]![List23]

The following is the error message " An error occurred while
referencing the object. You tried to run a Visual Basic procedure that
improperly references a property or method of an object."

Regards

0
Asif
5/11/2007 8:13:10 AM
On 11 May 2007 01:13:10 -0700, Asif <asifhashmani@hotmail.com> wrote:

>
>
>Thanks guys, I've tried to made the modifications as per your
>suggestions but unfortunately I'm still getting an error message
>
>Item:- [Forms]![frm_BinDetails]![frm_Cable].[Form]![txt_ProcessID]
>
>Expression:- [Forms]![frm_BinDetails]![frm_Cable].[Form]![List23]
>
>The following is the error message " An error occurred while
>referencing the object. You tried to run a Visual Basic procedure that
>improperly references a property or method of an object."
>
>Regards

I'd suggest you post in the microsoft.public.access.macros newsgroup  - I
never use macros and may be wrong about the syntax. Or... make the move to VBA
code, it will certainly work there (provided frm_BinDetails is open and has a
Subform control named frm_Cable with those control names).

             John W. Vinson [MVP]
0
John
5/11/2007 5:10:03 PM
Reply:

Similar Artilces:

subform in subform
Hi, I've got a form F and subform S1 in it. And inside S1 I've got subform S2. How do I reference a text box in S2 from VB code? thanx alek_mil Try: forms!F!S1!S2!textbox That should do the trick -- Maurice Ausum "alekm" wrote: > Hi, > I've got a form F and subform S1 in it. And inside S1 I've got subform S2. > How do I reference a text box in S2 from VB code? > thanx > > alek_mil You might find this useful as well... http://mvps.org/access/forms/frm0031.htm -- Jack Leach www.tristatemachine.com &q...

Inserting a blank row with a macro?
Hello everyone. Is there any way I can create a macro that will compare two cells such as B1 and B2 and if they dont' match to insert a blank row after B1? Thanks in advance. Aaron Sub CompareEm() If [B1].Value <> [B2].Value Then [B2].EntireRow.Insert End If End Sub You can usually figure out things like this by recording a macro while you do it manually, then modify the code. Jerry Aaron Russell wrote: > Hello everyone. Is there any way I can create a macro that will compare two > cells such as B1 and B2 and if they dont' match to insert a bl...

How To Stop Acces From Update The Record When The Subform Query Is On Focus?
Hi I need to know how to stop acces from update the record when the subform query is on focus? Thanks In news:1177155216.699820.268130@d57g2000hsg.googlegroups.com, Chipcom <bz1977@gmail.com> wrote: > > I need to know how to stop acces from update the record when the > subform query is on focus? If you mean that you want to keep the main form's record from being saved when the subform gets the focus, the only ways you can do that are: 1. Have the main form be unbound. In that case your own code has to do the job of reading the record, assigning its field values to ...

Macro Names display
In my reinstallation of Excel 2007, in the list of macros (Alt+F8) the name of the workbook containing the macro is displayed first followed by the macro name which makes it quite difficult to track down the one you are after. I don't think workbook names were shown in the previous installation of Excel. Is it possible to change the setting so only the macro names are displayed? "Pete" <pitsofea...@msn.com> wrote... >In my reinstallation of Excel 2007, in the list of macros (Alt+F8) >the name of the workbook containing the macro is displayed first >follow...

Textbox Information to Subform
I have a subform that I need to contain information from a main form. The sub form is linked by studentID, but I also need the tardy ID, TardyID, to populate the subDhall field txtTardyID. I tried the AfterUpdate of TardyID with this: Me!subDhall.txtTardyID=Me!frmTardyAdd.TardyID and Me!subDhall.frmTardyAdd.txtTardyID=Me!frmTardyAdd.TardyID to no avail. Anyone have any tips? -- Thanks As Always Rip "Ripper" <Ripper@discussions.microsoft.com> wrote in message news:753FE132-F478-4952-ABEE-EA884BB75A19@microsoft.com... >I have a subform that I need to contain informat...

Subform of a subform?
Is there a way to create a two subforms (sub1 and sub2) on one main form, but have the second subform (sub2) actually be a subform of the first (sub1)? ...

Macro Message Box
Hi, I am trying to build a macro for a histogram. When the macro is complete, I am asked "Histogram - Some data will be hidden by embedded chart(s)." I can click OK or cancel. How can I build my OK response into the macro so that I do not need to manually respond? Thank you for reviewing my question. Remove the MsgBox from the macro if it is unnecessary. -- HTH Bob "lahuwm" <lahuwm@discussions.microsoft.com> wrote in message news:ADD9273F-E393-4573-A3F5-BEEB344D21B0@microsoft.com... > Hi, I am trying to build a macro for a histogram. When...

Subform with Macro
I have a form (frm_BinDetails), within this form I have a subform (frm_Cable). frm_Cable has a listbox (List23) which when the user clicks on an entry the contents of the first column of that listbox are displayed in a textbox (txt_ProcessID). The on click event of the listbox runs a macro with the following code Action = SetValue Item = [Forms]![frm_Cable]![txt_ProcessID] Expression = [Forms]![frm_Cable]![List23] When I run the form frm_Cable on its own the macro works correctly but when I try and run from frm_BinDetails then whenever I click on an entry an error message appears saying th...

macros on a form
hi we have a workbook containing serveral worksheets each worksheet contains a lot of data we have split each worksheet into three pages for print purposes what we want to do is have a form containing drop down list of names we need each name to select and run a macro can this be done? thanks in advance kevin Kevin Carter Sigma Machining XL and VBA are capable of a lot. From the generic description of the problem, I would say yes. -- Regards, Tushar Mehta www.tushar-mehta.com Business solutions leveraging technology Microsoft Most Valuable Professional (MVP) 2000-2004 In art...

How do i make a macro "relative" to cell?
I know I want to make the macro relative, but I can't find the relative button. I record my macro, hit the tool button and tell it to stop recording. Where do I find the relative button? -- Thanks Very Much! Art Nittskoff Art, The relative button should be on the Stop Recording toolbar, with the stop button. You might have to use View - Toolbars - Customize to reset the Stop Recording toolbar to its factory state. -- Earl Kiosterud www.smokeylake.com/ ------------------------------------------- "Art Nittskoff" <ArtNittskoff@discussions.microsoft.com> wrote in me...

opening a subform to a specific record?
Hey y'all, I've got a form that lists all the Students in a class and a link to "Edit Student Information" which opens a form to edit individual records. The link uses the same type of code generated by the form wizard and it automatically filters the records to the class. The next thing I want to do is to open the new form to exactly the record that was highlighted in the list. I can capture the list position from the subform (SelTop) and I found a method called "GoToRecord" that works like this to go to the 8th record: DoCmd.GoToRecord acDataForm, "Studen...

Printing a single record from a tab control subform
Hi I have created a Case Management Database of students. It consists of a main form and a subform. The main form consists of information that must be seen at all times. since it consists of information about each student. The subform consists of a tab control. There is a different subject on each page of the tab contol, e.g. General Information, Current Student Information, etc. I need to print out the mainform and subforms so I created reports for each subform in my tab control. I want to put a "Print" button on each page of my tabcontrol so that when cl...

modifiying macros
I understand how to record a macro. But if I want to modify it (to repeat throughout the sheet), how do I access the code to mofidy? Thanks, KBV Alt + F11, double click on Modules then double click Module1. Should see your recorded code there. (May be other modules...ie 2, 3 etc.) Or right click on the sheet tab and click View Code. HTH Regards, Howard "KBV" <KBV@discussions.microsoft.com> wrote in message news:3D68B8D1-DA6E-42C7-ACDC-92DDE6CD4EEC@microsoft.com... >I understand how to record a macro. But if I want to modify it (to repeat > throughout the sheet),...

How to get a macro to do what i want?
I have designed a form in Excel and the data that is inputted i want to be able to save in a separate worksheet. The problem i am having is that eveytime i record the macro, it over writes the same row each time (if that makes sense). For example if i copied every cell in the form and paste them into the database Row 1, i then want the new piece of information inputted into the form to go into Row 2 and then Row 3 etc.... But it keeps going into Row 1, it wouldnt move down the rows. Hopefully this makes sense to someone and someone can give me some advise. Calculate the last row ...

Get Subform Data
I'm looking for a way to get the data from a chosen record in a continuous subform. I have a customer form and a continuous subform with all of the charges associated with the customer. Is it possible to have a button on the form, prompt the user to highlight a record (the charge info.) in the continuous subform and get the information about the charge? If there is not a way to do this, I'm pretty sure that I can achieve what I want to do via a list box. Open the subform in design view, and set its Record Selectors property to Yes. (This is a property of the Form, not o...

Error Macro?
In Microsoft outlook I wish to send a graphic e mail and get a window stating as follows C:\Documents and settings\******\application data\Microsoft\addins\wfoladin.dll is not a valid Office add-in How do I delete or remove this error any source of help would be most appreciated See if the info here helps: http://support.microsoft.com/kb/240230/en-us "belto" <belto@blueyonder.co.uk> wrote in message news:DdwYf.8768$zI1.2384@fe2.news.blueyonder.co.uk... > In Microsoft outlook I wish to send a graphic e mail and get a window > stating as follows > C:\Documents a...

Code to duplicate data from one subform to two other subforms
This is my first database so I hope I am able to talk the language well enough to get help. I have a form with three subforms. The 1st subform is titled Service Record subform and has fields for Department, Job Title, Date In, Date Out, and Time Served. The 2nd and 3rd subforms are Department Service and Job Title Service. I would like to be able to enter an employee's information in the 1st subform and have it populate the 2nd and 3rd subforms. I am wanting the Department Name along with time served to populate the 2nd subform and the Job Title Name and time served populate th...

Problem with Filtering Form with Subform in Acces Data Project 200
When I aplly filter (by form) to a form with subform in Acces Data Project 2007, subform loose data; subform does'n show any data; Moveing to next/prev. record in main form doesn't synchronise subform wich is still and always blank; I must close and reopen form to get again subform data... Main form contains about 50000 records and subform contains 30-60 records related to main form selected within 1,500,000 records in table. Moveing to next/prev. record work correctly when filter is not applied. Acces Data Project 2007 use SQL Server 2005 Express SP2 installed on Windows Vista...

Linking subforms on a tabbed page
Hello, I have a database that uses a main form with several tabbed pages. On one tabbed page I have two subforms. The first subform lists all the records in datasheet view. When the user selects a record in the first form it should display the details for that specific record in the second subform. I have created a hidden text field (txtRelay) that references the id field for the selected record in the first subform ([fsubSec_Data].[Form]![txtSecurityID]) and placed it on the tabbed page. I then have tried to link the records on the second form using the Master and Child fields....

Macro/SUB to merge two columns of text
EXCEL 2003: How do I write a VBA subroutine to: (1) Take each cell in the currently-SELECTED column (2) Append to its (text) contents the text in the corresponding cell of the NEXT column (3) Replace the result in the original cell (4) On completion, delete the whole of the NEXT column? All text values need to have leading and trailing blanks TRIMMED before being concatenated. This is to cope with the situation where downloaded data contains information split over two columns that the worksheet needs to have in one, e.g. company name and branch location. Sub m...

Subform within a subform
I have a subform (Person) which is nested within another subform (PersonalAssistant). Everything works fine except the foreign key in the PersonalAssistant subform. I have used the Link Child and Master Fields property to establish this link. In this case the primary key for the Person table is PersonID. Its an autonumber field which begins from 4000. When the foreign key is added by access, it takes the last digit or last two digits. So say the PersonID is 4001. What I see in the PersonalAssistant subform and table on the PersonID foreign key field is 1. On Mon, 11 Feb 2008 17:39:00 ...

Macro needed to Paste Values and prevent Macro operation
Sub Macro1() ' ' Dim myBk As Workbook Set myBk = Workbooks.Open(Application.GetOpenFilename(, , "Select the File")) Range("To_Database").Copy ThisWorkbook.Worksheets(1).Range("A65536").End(xlUp)(1).Offset(2, 1) myBk.Close False End Sub In the above macro I need to prevent macros operating in the External File when it opens. I also need the Named Range ("To_Database") from the External File to be copied into the file from which this macro operates as PasteValues. At the moment the Formula in the Named Range is coming across, so that I'm ...

Display balance on subform
I am trying to display a Stock Status report on a subform. The data comes initially from a union query which combines Stocktake data, Receipts and Issues. This is then sorted and the underlying query creates extra columns for Receipts, Issues and Balance. I have added a dummy first record to zeroise the Balance column. When the subform is first displayed, it is correct, but if the screen is scrolled, very strange things happen, like transactions being processed twice. Does anyone know whether this is possible in a datasheet subform - or do I need to go to continuous forms displayed a...

Macros?
I have been asked to streamline some time consuming data analysis (as I have mentioned with a different thread about a different question) and I'm wondering if Macros can help me. The manual process involves creating Excel documents from 4 CSV documents, then lots of cutting and pasting of values from one location to another. Then a few calculations are made and put into pretty graphs before being exported to word as a finished document. How much of this can be automated? Are macros the way to go? As far as I can tell, Macro's are embedded in a document aren't they? How can...

Speed up Form with 4 Subforms
Hello, I've got a time card database. Our office uses 4 types of time (Project, Admin, etc). I want to have a form that shows 4 sections -- one section for each type of time. I have successfully built the query that contains summary data for all time. No problem there. Currently, I have 4 sub-forms on the main form -- one subform for each type. On Form_Load, I bind the 4 subforms to the one query, with the "Forecast_Work_Type_Code" field deciding which data goes in which subform: Me!subfrm_Forecast_Summary_User_NonCSD.Form.RecordSource = "SELECT qry_Forecast_Summ...