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

Visual Basic Code

Hi,
I am just new at using this code, so have probably made a really simple mistake.
My code works fine just in the sub form I created it, but when putting the sub form in the main form, the code does not work as it says it "can't find the form SUPER Pension Sub Form referred to in a Macro Expression or Visual Basic. Code"

Code as follows:
Expand|Select|Wrap|Line Numbers
  1.  Dim stDocName As String
  2.  
  3.     stDocName1 = "SUPER Pension Request Letter TTR"
  4.     stDocName2 = "SUPER Pension Confirmation Letter"
  5.  
  6.     If Forms![SUPER Pension Sub Form]![Type of Pension] = 1 Then
  7.     DoCmd.OpenReport stDocName1, acPreview, , "[SUPER Pension Table]![Member Name]=Forms![SUPER Pension Form]![Member Name]"
  8.     Else
  9.     DoCmd.OpenReport stDocName2, acPreview, , "[SUPER Pension Table]![Member Name]=Forms![SUPER Pension Form]![Member Name]"
  10.     End If
If you could help it would be good. Thanks.
Sep 24 '07 #1
1 2021
Jim Doherty
897 Expert 512MB
Hi,
I am just new at using this code, so have probably made a really simple mistake.
My code works fine just in the sub form I created it, but when putting the sub form in the main form, the code does not work as it says it "can't find the form SUPER Pension Sub Form referred to in a Macro Expression or Visual Basic. Code"

Code as follows:
Dim stDocName As String

stDocName1 = "SUPER Pension Request Letter TTR"
stDocName2 = "SUPER Pension Confirmation Letter"

If Forms![SUPER Pension Sub Form]![Type of Pension] = 1 Then
DoCmd.OpenReport stDocName1, acPreview, , "[SUPER Pension Table]![Member Name]=Forms![SUPER Pension Form]![Member Name]"
Else
DoCmd.OpenReport stDocName2, acPreview, , "[SUPER Pension Table]![Member Name]=Forms![SUPER Pension Form]![Member Name]"
End If

If you could help it would be good. Thanks.

When a form is mounted on a main form it becomes subordinate to that main form when referencing controls on that subform. So you need to ensure you have the hierarchy referred to correctly.

Examine you code again and I think you will see where you have gone 'as you say' simple mistake

Clue
Forms![SUPER Pension Sub Form]![Type of Pension]

Answer
Forms!NameOfYourMainForm![SUPER Pension Sub Form].Form![Type of Pension]


Regards

Jim
Sep 24 '07 #2

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

Similar topics

26
by: Bruno Jouhier [MVP] | last post by:
I'm currently experiencing a strange phenomenon: At my Office, Visual Studio takes a very long time to compile our solution (more than 1 minute for the first project). At home, Visual Studio...
4
by: LCAdeveloper | last post by:
I have had to move to Visual Studio.NET Pro. from Visual Basic 4.0 and am now starting to re-write our code. I was a bit surprised to find that Visual Basic.NET no longer supports fixed length...
0
by: Dr. Zharkov | last post by:
Hello. To see the graphics of technology DirectX 9.0 SDK Update - June 2005 in project Visual Basic, WindowsApplication1 from Visual Studio 2005 Beta 1, in file My Project, MyApplication.vb in a...
2
by: elnahrawi | last post by:
Download ebook http://books-download.com/?Book=1487-Visual+Basic+2005+Jumpstart Okay, all you VB6 developers--time's up. As of March 2005, Microsoft no longer supports this version of Visual...
10
by: Steve | last post by:
I am trying to create a DLL in Visual Studio 2005-Visual Basic that contains custom functions. I believe I need to use COM interop to allow VBA code in Excel 2002 to access it. I've studied...
4
by: MikeB | last post by:
I've been all over the net with this question, I hope I've finally found a group where I can ask about Visual Basic 2005. I'm at uni and we're working with Visual Basic 2005. I have some books, ...
97
by: Master Programmer | last post by:
An friend insider told me that VB is to be killled off within 18 months. I guess this makes sence now that C# is here. I believe it and am actualy surprised they ever even included it in VS 2003 in...
2
by: sbweld | last post by:
Hello, I am using Powerpoint 2007 and have found an option to integrate visual basic code into the slides. I am building a standalone Kiosk and I want my powerpoint presentation to reset and go...
4
by: Chris Asaipillai | last post by:
Hi there My compay has a number of Visual Basic 6 applications which are front endeed onto either SQL Server or Microsoft Access databases. Now we are in process of planning to re-write these...
11
by: =?Utf-8?B?UGV0ZXI=?= | last post by:
I have seen the terms Visual Basic 2005 and VB.NET. It seems that sometimes they seem to be referring to the same thing but sometimes they are not. I also run into terms like VB9 and VB10.
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
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: 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: 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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
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...

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.