Newby question about code

G

GD

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!!
 
J

John Spencer (MVP)

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
 
J

John W. Vinson

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!
 
T

Tony Toews [MVP]

GD said:
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/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top