473,324 Members | 1,678 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

How to reference parent form from subform when parent name can be different

374 256MB
All,

I want to reference a button on the parent form of a subform. The parent however could be two different form names.

frmlog

frmcorrective

How do I check which form is loaded in order to create the reference to the correct parent? The parent will always be loaded at the time the subform is being used.

I think the correct syntax for referencing a parent is along the lines of:

Forms!frmlog!tglchange.enabled = true

Thanks for any help,

Chris
Sep 14 '10 #1

✓ answered by munkee

Couldnt get sourceobject working correctly but I managed with this:

Expand|Select|Wrap|Line Numbers
  1. If Me.Parent.Name = "frmlog" Then
  2.     MsgBox "frmlog"
  3. ElseIf Me.Parent.Name = "Frmcorrective" Then
  4.     MsgBox "frmcorrective"
  5. End If

5 29684
TheSmileyCoder
2,322 Expert Mod 2GB
I think something like this would work for you:

Expand|Select|Wrap|Line Numbers
  1. If me.Parent.SourceObject="frmLog" Then
  2.    me.Parent.form.tglChange.Enabled=True
  3. elseif me.parent.sourceobject="frmCorrective" then
  4.   'blah blah
  5. end IF
Sep 14 '10 #2
munkee
374 256MB
damnit! thats was so obvious why did I not even think.. thanks!


Hmm for some reason it keeps only referencing frmlog when I load the code whilst using frmcorrective.
Sep 14 '10 #3
TheSmileyCoder
2,322 Expert Mod 2GB
I believe, that subforms are loaded before main forms.
I remember messing around with this at some point, and in the end i put alot of msgbox "frm_Thisform opening", msgbox "frm_thisForm Loading" to try to determine the order of loading. I'd suggest trying that.
Sep 14 '10 #4
munkee
374 256MB
Couldnt get sourceobject working correctly but I managed with this:

Expand|Select|Wrap|Line Numbers
  1. If Me.Parent.Name = "frmlog" Then
  2.     MsgBox "frmlog"
  3. ElseIf Me.Parent.Name = "Frmcorrective" Then
  4.     MsgBox "frmcorrective"
  5. End If
Sep 14 '10 #5
TheSmileyCoder
2,322 Expert Mod 2GB
Yes of course. I'm used to using it a bit the other way around, where im in the parent, and want to know which subform is currently displayed. The sourceobject is only used for a control containing a form.

I believe you can choose your own reply as "best answer", so the thread gets marked as answered.
Sep 14 '10 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

25
by: Lyn | last post by:
Hi, I am working on a genealogy form. The only table (so far) lists everybody in the family, one record per person. Each record has an autonum ID. The parent form (frmMainForm) displays the...
1
by: tdmailbox | last post by:
I have the statment below that turns off allow edits so thatwhen I run the commend acCmdFind I only see the find menu rather then find and replace. The search button is on the parent form,...
5
by: Ron | last post by:
Hi All, I've got a form called frmCust that has a subform on it called sfrmBalance. sfrmBalance's control source is a query called qryTrans4CustBal. sfrmBalance has one field on it called...
4
by: brookdb | last post by:
I have three forms we'll call, "Mainform A", "Mainform B" and "Mainform C" in which there is a subform, "Subform" and inside my subform I have another subform, "Sub-Subform". It is paramount to my...
3
by: =?Utf-8?B?aWxy?= | last post by:
Hi All I am developing an vb 2005 winforms application that connects to a database and displays a datagridview of the data. A user can select and then edit, or create a new entry by opening a...
13
by: bitsnbytes64 | last post by:
Hi, I have a form which contains a subform. Both are were creetd using the form wizard and are bound by the column IXO_NR (on two different tables), which is the control source for a textbox on...
6
by: solom190 | last post by:
Okay this is the situation I have two forms and they have a 1:M relationship. I don't have enough space screen-wise to do a traditional "drag form to form" to create a subform so what I did was...
8
by: harvindersingh | last post by:
Hello guys I have some custom events in my application i.e. KeyPress such as full screen for pressing F11 and so on. Currently this works fine but only when the main form which is listening tot he...
0
by: sudhirb | last post by:
Hello I am using MS Access 2003. I have a parent form based on parent table which contains unique ID field( primary key) which i enter first on the parent form. Parent table also contains fields...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.