472,783 Members | 877 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,783 software developers and data experts.

Concept Question

I am having a conceptual problem.
When working with a forms & Code sections which is correct method and how do
they differ when working with fields?
Code
Private Sub CExt1_BeforeUpdate(Cancel As Integer)
Me!CExt1 = Nz([CDoz1], 0) * Nz([CPrice1], 0) ; this one?
CExt1 = Nz([CDoz1], 0) * Nz([CPrice1], 0) : Or this?
End Sub

Form Control Source
CExt1 = Nz([CDoz1], 0) * Nz([CPrice1], 0) Or is this correct way
to do it?
My problem is when do you use the Me! with a field and when is it not
needed. Or just what the heck is the concept behind them...

Thanks,

JC
Nov 12 '05 #1
2 1461
Some of it is personal preference. Using Me makes it a little more apparent
when reading the code that it is an item on the form/report, not just a
variable. This would be similar to putting "int" on the front of an integer
variable (i.e. intMyVariable). It will also sometimes remove problems if you
have duplicate names because it pins down which item you are referring to;
however, it is better to remove the duplicate names.

As far as placing the equation in the control source, if you do that you now
have a calculated control that the user can't type information into. If
that's what you're after, then that's probably the better way. If you want
the control to be a bound control and you want to change it programmatically
also, then you can't put the equation in the control source. By the way, I
don't know if you just did this for the message or not, but if it is put in
the control source, the name of the control on the left side of the equal
sign isn't entered, it automatically refers to the control whose control
source it is in.

Example:
CExt1 = Nz([CDoz1], 0) * Nz([CPrice1], 0) Change the above to
= Nz([CDoz1], 0) * Nz([CPrice1], 0)
When placing it in the control source of the control CExt1. Also, Me won't
be recognized here.

--
Wayne Morgan
Microsoft Access MVP
"JC Mugs" <jc****@hotmail.com> wrote in message
news:10*************@corp.supernews.com... I am having a conceptual problem.
When working with a forms & Code sections which is correct method and how do they differ when working with fields?
Code
Private Sub CExt1_BeforeUpdate(Cancel As Integer)
Me!CExt1 = Nz([CDoz1], 0) * Nz([CPrice1], 0) ; this one?
CExt1 = Nz([CDoz1], 0) * Nz([CPrice1], 0) : Or this?
End Sub

Form Control Source
CExt1 = Nz([CDoz1], 0) * Nz([CPrice1], 0) Or is this correct way to do it?
My problem is when do you use the Me! with a field and when is it not
needed. Or just what the heck is the concept behind them...

Thanks,

JC

Nov 12 '05 #2
"JC Mugs" <jc****@hotmail.com> wrote in
news:10*************@corp.supernews.com:
I am having a conceptual problem.
When working with a forms & Code sections which is correct method and
how do they differ when working with fields?
Code
Private Sub CExt1_BeforeUpdate(Cancel As Integer)
Me!CExt1 = Nz([CDoz1], 0) * Nz([CPrice1], 0) ; this one?
CExt1 = Nz([CDoz1], 0) * Nz([CPrice1], 0) : Or this?
End Sub

Form Control Source
CExt1 = Nz([CDoz1], 0) * Nz([CPrice1], 0) Or is this correct
way to do it?
My problem is when do you use the Me! with a field and when is it not
needed. Or just what the heck is the concept behind them...

Thanks,

JC


I almost always use

Me.NameofControl.Value

Is it slower? I'm not sure. Does it remind me that I am dealing with a
control property of the form? Yes. Can I find it in Intellisense? Every
Time.

I am also careful to name my controls with prefixes, txt, cmd, lst, cbo etc
and to be sure that their names are distinct from any fields to which they
may be bound. I name their labels by replacing the prefix with lbl. So
typically, a control lonked to a field called fldFirstName is called
txtFirstName and its label is called lblFirstName.

For fields in the recordsource I wish to use but not see, I create hidden
controls, and name and point to them in the same way.

I haven't used a bang in a very long time.

--
Lyle
(for e-mail refer to http://ffdba.com/contacts.htm)
Nov 12 '05 #3

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

Similar topics

3
by: Matthew Louden | last post by:
I want to know if the PostBack concept applies to HTML web-based forms, regardless of what programming technologies we use: For example, ASP, ASP.NET, Java, CGI, etc... PostBack means to send...
1
by: googleo | last post by:
Hi, in my application I want to handle and store data in a hierarchic data structure. For example: persons who manage houses; houses have various numbers of floors; floors have various numbers...
6
by: Sergey | last post by:
Hello! Could anybody be kind enough to explain this concept? Why C++ make two ops for prefix and postfix ++ operator? As I guess, it is possible to implement both cases via sole prefix...
4
by: cmc | last post by:
I need some clarification to help me understand the DB2 strucure more. The questions are about "implicit schema" 1. This is a very interest concpet that DB2 let every user to create new schema...
4
by: jm | last post by:
Consider: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbconwhenshouldiimplementinterfacesinmycomponent.asp // Code for the IAccount interface module. public...
5
by: strutsng | last post by:
I want to clarify the concept of submitting the form to the web server. PHP is just an example here, it applies to any web programming languages. On page1.php, <form name="myform"...
20
by: Stan Sainte-Rose | last post by:
Hi, Sorry about this newbie question, but I have some questions about the MDI Concept. I have a MdiParent form that calls a Child Form (A). This Child Form (A) could call another Form (B). ...
2
by: developer.new | last post by:
Hi I have a question regarding this concept I learned about recently: Name Hiding. Here's what I've come across: There is a base class with two functions with the same name but different...
2
Subsciber123
by: Subsciber123 | last post by:
I am writing a program to create family trees. It is stable, but I would say that it is still in the pre-alpha stage. Anyway, I would like to be able to export the tree to a concept map. Does...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?

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.