Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Developer Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Insert a string value in VBA
Gary Becker 
     
3 years ago
For the sake of class, I'm trying to create a function in my GlobalMod that returns the size of a form. I created the function ThisFormSize that I call from a command button on a form to return the name of that form. And that part seems to be working. The first msgbox returns the name of the form. The second msgbox is returning the window height of the MainMenuF. I want to insert value returned by the function, i.e. the form name, where the form name is hard coded. I've tried all sorts of ampersands, quotes, double quotes, double double quotes and I can't get it to work. How should it be?
Gary Becker OP  @Reply  
     
3 years ago

Gary James  @Reply  
      
3 years ago
You say "I want to insert value returned by the function", yet your code isn't doing anything with the value returned by your function.    You need to write out a list of steps that you want to perform, then look at how to code those steps.   From your example it's not obvious what you're trying to do.
Gary Becker OP  @Reply  
     
3 years ago
The global function is returning the form name that is calling it (it's being called from an On Click event of a button)--that part is working. And to check that, I message boxed the string variable that it's returning. The first message box is only to verify that it's returning the correct string value. In the second message box, the form name is "hard coded" in and it does return the window height. What I am trying to do--is to replace the form "name" where it says Forms! [here is where the string variable goes that contains the form name].WindowHeight. I've tried this: Forms! & ThisFormSize & .WindowHeight.  I've tried: Forms! & ""ThisFormSize"" & .WindowHeight. And lots of other variations with ampersands and quotes. I can't get the syntax correct, I guess. What is the correct syntax?
Gary Becker OP  @Reply  
     
3 years ago

Kevin Robertson  @Reply  
          
3 years ago
Try this:

Forms(ThisFormSize).WindowHeight
Gary Becker OP  @Reply  
     
3 years ago
Yes, that works. Now I see that using the parenthesis is like the syntax of the CurrentProject.Allforms(ThisFormName).Name

But I never would have thought of it. Thanks so much.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Developer Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 5/8/2026 9:51:29 PM. PLT: 0s