473,398 Members | 2,525 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,398 software developers and data experts.

VB/Menus

Hi,

I have a number of button-driven functions/subs that I'd like to
migrate to menu items. I have one problem however.

In a button-driven sub I would refer to a field in the current form as,
for example, 'Me.Name' or 'Me.Tel'. However this doesn't work when the
code is used in a menu. I've also tried Me!Name.

I'd appreciate to a any pointers as to how I refer to fields in the
current form in a menu.

Thanks

Emmett

Nov 13 '05 #1
3 1245
Forms!MyForm!MyField

Note that the form must be open.

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
re******@pcdatasheet.com
www.pcdatasheet.com
<Em****@Silico-Research.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
Hi,

I have a number of button-driven functions/subs that I'd like to
migrate to menu items. I have one problem however.

In a button-driven sub I would refer to a field in the current form as,
for example, 'Me.Name' or 'Me.Tel'. However this doesn't work when the
code is used in a menu. I've also tried Me!Name.

I'd appreciate to a any pointers as to how I refer to fields in the
current form in a menu.

Thanks

Emmett

Nov 13 '05 #2
That's worked great. Thanks for your help.

Regards

Emmett

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #3
99% of the time the code is in the form, so you don't have to change
anything.

The only change you need to your button code is to make it a public
Function.

So, if you have a button on the current from to print the current record,
the code would look like:
me.Refresh ' force a disk write

docmd.OpenReport "invoice",acViewPreview,,"id = " & me!id

To move the above code to a button on a custom menu, we would change the
button code to:

PrintInvoice

And, then cut and past out the code right below to:

Public Function PrintInvoice
me.Refresh ' force a disk write

docmd.OpenReport "invoice",acViewPreview,,"id = " & me!id
end function.
Then, in the menu's on-action, you simply go:

=PrintInvoice()

All of the code for the button and form SHOULD and can remain in the current
form. There is NO reason to start re-writing the actual code, and changing
references like me. to forms!YourFormname. This is simply not required at
all.
--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pl*****************@msn.com
http://www.members.shaw.ca/AlbertKallal
Nov 13 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
by: chart43 | last post by:
I have question about the technique for css dropdown menus described in http://www.alistapart.com/articles/horizdropdowns/. Based on an html list, it has a few items in a 1st order list and further...
7
by: Marci | last post by:
I found this script for cascading menus, however, I cannot reach the author to solve the bug I am having when I add a second menu to it. My problem is this: If I click on the first link, the...
2
by: Pete | last post by:
In Access 95/97 I used to be able to create pull down menus (File,Edit ...) from a macro. It seems there used to be some wizard for that. However in Access 2000 it seems you have to build your...
1
by: cefrancke | last post by:
I have set the Startup properties to the following... All menus, toolbars, etc are turned off plus these are unchecked Allow Full Menus Allow Built-in Toolbars Allow Default Shortcut Menus...
3
by: cefrancke | last post by:
The only reason I ask is that no one has made this subject clear or given a definitive answer. What I would like to do is, after turning off all the menus/tbars/etc using the startup options. ...
0
by: cefrancke | last post by:
I recently discovered, that if you set the startup options for "security", you will have alot of work do to get Access back to "normal". If you disable the built-in menus/toolbars you'll have to...
4
by: Karl Irvin | last post by:
I distribute an A 2000 app as a mde. On a few customers, my custom menus are overwritten. The top menu is generally there but the choices on the menus are gone or replaced by something else. ...
0
by: Keith | last post by:
When merging two menus, it doesn't actually merge their sub menus and menu items It only displays two menus on one forms instead of merging two sub menus into one if they have sam menu text ...
3
by: Steven Smith | last post by:
the way I'm undersatnding the MSDN documentation when creating parent and child forms the main menu for the child form should not be displayed on the child form itself but instead be incorporated...
0
by: ARC | last post by:
Hello all, For right-click (shortcut) menus in access 2007, I've been using a round-about method of opening access 97 on an old computer, modifying my own custom shortcut menus, then importing...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.