A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » New Users
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Newby question about code



 
 
Thread Tools Display Modes
  #1  
Old January 8th, 2009, 04:26 PM posted to microsoft.public.access.gettingstarted
gd
external usenet poster
 
Posts: 209
Default Newby question about code

Does it matter if code syntax or entries are changed (or typed over) after
the fact? Is the function thereby altered or disrupted?

For example, if I change the table name in:

If Val(DLookup("[Level]", "tblUsers", "[UserID]='" & CurrentUser() &
"'")) = 2 Then
boxDCMgt.Visible = False
Else
boxDCMgt.Visible = True
End If

to:

If Val(DLookup("[Level]", "004UserAuth_tbl", "[UserID]='" &
CurrentUser() & "'")) = 2 Then
boxDCMgt.Visible = False
Else
boxDCMgt.Visible = True
End If

will the code still work? Or if I add Me. to my boxes after the code is
already written:

If Val(DLookup("[Level]", "004UserAuth_tbl", "[UserID]='" &
CurrentUser() & "'")) = 2 Then
Me.boxDCMgt.Visible = False
Else
Me.boxDCMgt.Visible = True
End If

should that have any effect?

Thanks for your time!!

--
GD
  #2  
Old January 8th, 2009, 05:37 PM posted to microsoft.public.access.gettingstarted
John Spencer (MVP)
external usenet poster
 
Posts: 217
Default Newby question about code

Since the code is interpreted at runtime, then when you make changes the
changes take place.

Well, the code is interpreted at runtime unless it has been compiled. If it
has been compiled (and not changed) the story is slightly different. BUT,
when you make a change the compiled code for that procedure is ignored and the
code is interpreted.

So if you change the code, you change the behavior.

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County

GD wrote:
Does it matter if code syntax or entries are changed (or typed over) after
the fact? Is the function thereby altered or disrupted?

For example, if I change the table name in:

If Val(DLookup("[Level]", "tblUsers", "[UserID]='" & CurrentUser() &
"'")) = 2 Then
boxDCMgt.Visible = False
Else
boxDCMgt.Visible = True
End If

to:

If Val(DLookup("[Level]", "004UserAuth_tbl", "[UserID]='" &
CurrentUser() & "'")) = 2 Then
boxDCMgt.Visible = False
Else
boxDCMgt.Visible = True
End If

will the code still work? Or if I add Me. to my boxes after the code is
already written:

If Val(DLookup("[Level]", "004UserAuth_tbl", "[UserID]='" &
CurrentUser() & "'")) = 2 Then
Me.boxDCMgt.Visible = False
Else
Me.boxDCMgt.Visible = True
End If

should that have any effect?

Thanks for your time!!

  #3  
Old January 8th, 2009, 05:47 PM posted to microsoft.public.access.gettingstarted
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Newby question about code

On Thu, 8 Jan 2009 08:26:45 -0800, GD wrote:

Does it matter if code syntax or entries are changed (or typed over) after
the fact? Is the function thereby altered or disrupted?


You should always use Debug... Compile after making changes; correct any
errors that the compiler discovers; and save the project with the diskette
icon on the toolbar - but no, the reason that VBA has a code editor window is
that they assume you'll be editing your code!
--

John W. Vinson [MVP]
  #4  
Old January 8th, 2009, 07:51 PM posted to microsoft.public.access.gettingstarted
Linq Adams via AccessMonster.com
external usenet poster
 
Posts: 1,474
Default Newby question about code

Also keeping in mind that, in the case of DLookup() and other functions of
its ilk, the syntax for the Criteria argument changes slightly, depending on
the Datatype.

"[UserID]='" & CurrentUser() & "'"

will work because CurrentUser() returns a Text field, but if you substitute
another type of field here, such as a Numeric or Date/Time field the code
would fail.

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000/2003

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...arted/200901/1

  #5  
Old January 8th, 2009, 08:33 PM posted to microsoft.public.access.gettingstarted
Tony Toews [MVP]
external usenet poster
 
Posts: 3,776
Default Newby question about code

GD wrote:

If Val(DLookup("[Level]", "tblUsers", "[UserID]='" & CurrentUser() &
"'")) = 2 Then
to:

If Val(DLookup("[Level]", "004UserAuth_tbl", "[UserID]='" &
CurrentUser() & "'")) = 2 Then


Now why would you want to put a 004 in front of the table name? This
sounds like it might violate normalizing recommendations/rules.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 02:01 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.