473,394 Members | 1,831 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,394 software developers and data experts.

How to Display Subform Value on the Main Form

418 256MB
I am trying to display a value from the sub form on to the main form. It's not a calculated data, just plain text.

This is what I attempted without success.

1. Created a text box called "Hero" within the subform [sfrmItemsCast] footer.
2. In its control source I added this function:
=iif(([icrSort] = 1,[iccID]),"")
3. Created another text box on the main form and added this in its control source:

=[sfrmItemsCast].Form![Hero]

But I am getting this error message: #Name? I should mention that icrSort is a text field.

My goal is to display the hero's name in a fancy font up on the main form.

Can anyone please help me with this problem? Thanks a lot.
Jun 5 '10 #1

✓ answered by ADezii

@MNNovice
This should do the trick:

24 5994
ADezii
8,834 Expert 8TB
@MNNovice
Try this in the Control Source of the Text Box in the Main Form:
Expand|Select|Wrap|Line Numbers
  1. =IIf(Forms!<Form Name>![sfrmItemsCast].[Form]![icrSort]="1",Forms!<Form Name>![sfrmItemsCast].[Form]![iccID],"")
Jun 6 '10 #2
MNNovice
418 256MB
@ADezii
Adezeii:

I modified the code to match names of my forms. But I am getting this "invalid syntax" error message that reads: "You have entered a comma without a preceding value or identifier"

Expand|Select|Wrap|Line Numbers
  1. =IIf(Forms!<fItems>![sfItemsCast].[Form]![icrSort]="1", Forms!<fItems>![sfItemsCast].[Form]![iccID], "")
  2.  
Thanks for looking into my problem. M
Jun 6 '10 #3
ADezii
8,834 Expert 8TB
@MNNovice
Any chance of Uploading the Database?
Jun 7 '10 #4
MNNovice
418 256MB
@ADezii
Certainly. Please see the attached.

Main form: fItems
Sub form: sfItemsCast

I am trying to display names of the main characters (1 and 2) on fItems. Currently it's showing as "#Name?"

Thanks for your time and effort.
Jun 7 '10 #5
ADezii
8,834 Expert 8TB
@MNNovice
It appears to me, that what you are requesting can be accomplished via the Current(0 Event of the sfItemsCast Sub-Form. Delete the Control Sources for the Tetxt Boxes on the Main Form, then Copy-and-Paste this Code into the Current Event of the Sub-Form:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current()
  2. 'Heroine Text Box in Main Form
  3. If Me![icrSort] = 1 Then
  4.   Forms!fItems![Text51] = Me![iccID]
  5. Else
  6.   Forms!fItems![Text51] = ""
  7. End If
  8.  
  9. 'Hero Text Box in Main Form
  10. If Me![icrSort] = 2 Then
  11.   Forms!fItems![Text52] = Me.[iccID]
  12. Else
  13.   Forms!fItems![Text52] = ""
  14. End If
  15. End Sub
Jun 7 '10 #6
MNNovice
418 256MB
@ADezii
ADezii:

Sorry but it didn't work. I get blanks on fItems.

As suggested I made the two text boxes on fItems "Unbound".

Added the following codes on Current of the sfItemsCast:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current()
  2.  
  3. 'Heroine Text Box in Main Form
  4. If Me![icrSort] = 1 Then
  5. Forms!fItems![Heroine] = Me![iccID]
  6. Else
  7.  
  8. Forms!fItems![Heroine] = ""
  9.  
  10. End If
  11.  
  12. 'Hero Text Box in Main Form
  13. If Me![icrSort] = 2 Then
  14. Forms!fItems![Hero] = Me.[iccID]
  15. Else
  16. Forms!fItems![Hero] = ""
  17. End If
  18.  
  19.  
  20. End Sub
I have replaced Text51 and Text52 with "Hero" and Heroine respectively. What am I doing wrong? I didn't get any error message but the unbound text boxes on fItems does not even display although the visible is set to YES.

Thanks.
Jun 7 '10 #7
ADezii
8,834 Expert 8TB
@MNNovice
Text51 and Text 52 remain the same, and do not change.
Jun 7 '10 #8
MNNovice
418 256MB
@ADezii
Even though on sfItems Footer, I changed the names of these two text boxes (Text51 to Heroine and Text52 to Hero)?
Jun 7 '10 #9
ADezii
8,834 Expert 8TB
@MNNovice
I am referring to the Text Boxes on the Main Form, as per the Attachment:
Attached Files
File Type: zip 060710_DVD_2.zip (659.4 KB, 216 views)
Jun 7 '10 #10
MNNovice
418 256MB
@MNNovice
Okay. I see what you mean. But why no names is being displayed on the main form? Why those two text boxes do not even show up? On record no. 1, it should read as "Suchitra Sen" and "Uttam Kumar" for example. But they remain blank and invisible. Why is that?
Jun 7 '10 #11
ADezii
8,834 Expert 8TB
@MNNovice
Because you are referring to the Current Record on the Sub-Form the way I read it. Put the Cursor on a Record with an ID of either 1 or 2 in the Sub-Form.
Jun 8 '10 #12
MNNovice
418 256MB
@ADezii
Okay. It works but not the way I intended. First of all, it displays the iccID and NOT the name associated with it.

If I were to put my cursor on an ID - it beats the purpose. I intend to automatically display the names of those actors who play the main roles (icrSort = 1 and 2 or Hero or Heroine) in a given movie.

Hope this makes sense. Thanks again for your help. M
Jun 8 '10 #13
NeoPa
32,556 Expert Mod 16PB
Subscribing for later :)
Jun 8 '10 #14
ADezii
8,834 Expert 8TB
@MNNovice
How about Posting some specific examples from Records contained within the Sub-Form from the Demo DB, listing the specific Main Record Number, Sub-Form Record(s), Hero/Heroine's Name, etc. This is one of those problems that is very hard to conceptualize from the opposite end of a Web Page (LOL).
Jun 8 '10 #15
ADezii
8,834 Expert 8TB
@NeoPa
I'm really off on a Tangent on this one, think you can have a look-see?
Jun 8 '10 #16
MNNovice
418 256MB
@ADezii
ADzeii:

1. Consider the very first record iID 1.
2. on the main form fItems, the title (Haarano Shoor) is displayed on the Main Form's header section.
3. I am trying to get the names of the main role players displayed on the form's header section as well. So basically for iID #1, these names will be a)Heroine: Suchitra Sen and b) Hero: Uttam Kumar
4. Issue: I had no problem getting the title displayed as this data resides on the Main Form fItems. But the names of the main role players reside inside the sub form sfItemsCast. So my question is how do I accomplish the goal stated above in item#3?

Hope this explains my objective. Thanks.
Jun 8 '10 #17
NeoPa
32,556 Expert Mod 16PB
I will certainly try when I can ADezii, but that's unlikely to be for a few days I'm afraid. Lots going on at the moment and this appears to be one that will take a certain amount of time just understanding the question and catching up etc.
Jun 8 '10 #18
MNNovice
418 256MB
@NeoPa
NeoPa:

I appreciate your time and willingness to help me. Thank you very much.

M
Jun 8 '10 #19
ADezii
8,834 Expert 8TB
@NeoPa
Thanks NeoPa, but I do believe that I have found a solution, although in a different manner. Thanks.
Jun 8 '10 #20
ADezii
8,834 Expert 8TB
@MNNovice
This should do the trick:
Attached Files
File Type: zip 060710_DVD_3.zip (658.9 KB, 209 views)
Jun 8 '10 #21
MNNovice
418 256MB
@ADezii
ADzeii:

Awsome. This is exactly what I was looking for. Your effort and time in helping me is much appreciated.

Please unload the zipped file of my DB from this site.

Until next question. Thanks for teaching me a new trick. MNNovice
Jun 9 '10 #22
NeoPa
32,556 Expert Mod 16PB
I hope to get time to look at this tomorrow (Thursday) so let me know if ADezii's latest solution solves the issue.
Jun 9 '10 #23
MNNovice
418 256MB
@NeoPa
NeoPa:

Thanks for checking. Yes, ADzeii's solution worked just fine. But I was going to ask if it's possible to explain how does it work. This is only for my own learning.

He created a query for the sub form. Then added the following code in the text boxes on the main form:

Expand|Select|Wrap|Line Numbers
  1. =DLookUp("[Name]","qrySubForm","[iciID]=" & Forms!fItems!iID & "AND [icrSort] = '1'")
My understanding of this code:

Dlookup Name from the qrySubForm where iciID matches the iiD of the main form fItems AND icrSort equals 1.

Is my understanding correct?

Thanks.
Jun 9 '10 #24
NeoPa
32,556 Expert Mod 16PB
Yes. It is certainly correct :)
Jun 9 '10 #25

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

Similar topics

1
by: iggie | last post by:
Hello, everyone. How can I display text from another form that currently has the focus. I'm doing a search in sql 2000, to dot it. I call a search form and query my criteria, when it founds the...
1
by: William Starr Moake | last post by:
The browser-based WYSIWYG editor I'm developing has a popup window with a form that generates table code from user input (width, border, cols, rows, bgcolor.) But the user has to copy-paste the...
1
by: Hasanain F. Esmail | last post by:
Hi All, I am using A2 for this database. I have a main form with bound fields of FlightNumber and FlightDate I also have a subform. This subform takes details of a passanger along with other...
5
by: Randy | last post by:
The following code, which runs when I click File->Save in my main form, finds my save button in my mdi child for just fine. The question is: how do I invoke the Save method in the child form? ...
1
by: gourab | last post by:
How to write a code to hide a form and show another form?
1
by: Bface | last post by:
Hi All, I am stuck on a problem and hope someone can help me out. I have 8 users who will be using a form . For the users to access their accounts I use the SendKeys function, the user click on...
1
by: viksha | last post by:
Hi, I need help to get sum of field in subform to main form field I am using Mainform's field (total) default value =Sum(!!) Please help
2
by: franc sutherland | last post by:
Hello, I am using Access 2003. I have a query which shows a list of club meetings sorted by date. This query is displayed in continuous forms, in a subform. I would like to select a month on...
6
by: mjworks2009 | last post by:
I'm creatig a data base and in my front page i have 3 sub forms and 3 buttons for the sub forms to activate or not. 1. Subform1 is where all the current list of the patients being admitted for...
5
by: AccessBeetle | last post by:
I have a table bound main form.It is a simple data entry form. It has 5 tabs and each tab contains a subform. There is a checkbox called chkShortRpt. I want something like this: When user clicks on...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.