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

Simple ? on VBA (I hope)

OM
Can someone tell me why, in Event Procedures that are generated by MS
Access, (say to open a form, as below), the form name is entered as a
variable stDocName. Why not just use the form name itself ? Or is there a
good reason not to? I would guess the same arguments apply to stLinkCriteria
?

ie why

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmIncidentHeader"
DoCmd.OpenForm stDocName, , , stLinkCriteria
rather than

DoCmd.OpenForm frmIncidentHeader, , , fldQNIEV=100
Thanks folks

Rob Lepper
Jan 13 '07 #1
2 1548
There is no need to create variables for these simple examples.

But it might be a good idea. Sometimes you want to add more code that refers
to the form once it's open, so you can do that with:
Forms(stDocName)

Other times, the criteria can get quite complex (several clauses, even
subqueries that look up values in tables that are not in the form's
RecordSource). You can simplify the debugging process by adding the line:
Debug.Print stLinkCriteria

My personal preference is that I use a variable for the WhereCondition most
of the time, but only use one for the form name if I will refer to it more
than once.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"OM" <OM@youknowwhere.comwrote in message
news:45**********************@news.optusnet.com.au ...
Can someone tell me why, in Event Procedures that are generated by MS
Access, (say to open a form, as below), the form name is entered as a
variable stDocName. Why not just use the form name itself ? Or is there a
good reason not to? I would guess the same arguments apply to
stLinkCriteria ?

ie why

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmIncidentHeader"
DoCmd.OpenForm stDocName, , , stLinkCriteria
rather than

DoCmd.OpenForm frmIncidentHeader, , , fldQNIEV=100
Thanks folks

Rob Lepper
Jan 13 '07 #2
OM
Thanks Allen. I thought that maybe it was something like that, but wasn't
sure.

Rob Lepper

"Allen Browne" <Al*********@SeeSig.Invalidwrote in message
news:45***********************@per-qv1-newsreader-01.iinet.net.au...
There is no need to create variables for these simple examples.

But it might be a good idea. Sometimes you want to add more code that
refers to the form once it's open, so you can do that with:
Forms(stDocName)

Other times, the criteria can get quite complex (several clauses, even
subqueries that look up values in tables that are not in the form's
RecordSource). You can simplify the debugging process by adding the line:
Debug.Print stLinkCriteria

My personal preference is that I use a variable for the WhereCondition
most of the time, but only use one for the form name if I will refer to it
more than once.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"OM" <OM@youknowwhere.comwrote in message
news:45**********************@news.optusnet.com.au ...
>Can someone tell me why, in Event Procedures that are generated by MS
Access, (say to open a form, as below), the form name is entered as a
variable stDocName. Why not just use the form name itself ? Or is there a
good reason not to? I would guess the same arguments apply to
stLinkCriteria ?

ie why

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmIncidentHeader"
DoCmd.OpenForm stDocName, , , stLinkCriteria
rather than

DoCmd.OpenForm frmIncidentHeader, , , fldQNIEV=100
Thanks folks

Rob Lepper

Jan 13 '07 #3

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

Similar topics

3
by: Patchwork | last post by:
Hi Everyone, Please take a look at the following (simple and fun) program: //////////////////////////////////////////////////////////////////////////// ///////////// // Monster Munch, example...
4
by: ³\¥\»\ | last post by:
I have reviewed all famous and mature CMS but there are ALL too complicated, too fancy and the result is that you can not totally control what you want in your website. I hope there is a CMS with:...
6
by: francisco lopez | last post by:
ok , first of all sorry if my english is not so good, I do my best. here is my problem: I don´t know much javascript so I wrote a very simple one to validate a form I have on my webpage. ...
5
by: rcamarda | last post by:
I need a sql statment to return a list of tables for a given database where the Recovery Model option is Simple. TIA Rob
6
by: wooks | last post by:
Sorry if this is very basic. I have bought a Functional Programming book that uses the language Hope. I have managed to locate and extract Ross Pattersons hope interpreter from...
5
by: Stephanie_Stowe | last post by:
Hi. I am trying to get used to AS.NET. I have been doing ASP classic for years, and am now in a position to do ASP.NET. I am in the stumbling around until I get my bearings phase. I hope you will...
6
by: kamazoo | last post by:
I have no programming experience whatsoever, but nevertheless am I currently responsible for an update of a website, where a few hotels can be booked using an orderform. The website is built with...
1
by: tomer.ha | last post by:
Hi there, I'd like to send emails from a Python program using Simple MAPI. I've tried this code: http://mail.python.org/pipermail/python-list/2004-December/298066.html and it works well with...
6
kenobewan
by: kenobewan | last post by:
Congratulations! You are one of the few who realise that over 80% of errors are simple and easy to fix. It is important to realise this as it can save a lot of time. Time that could be wasted making...
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: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: 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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.