Computer Learning Zone CLZ Access Excel Word Windows

A leader is judged not by the length of his reign but by the decisions he makes.

-Klingon Proverb
 
Home   Courses   Index   Templates   Seminars   TechHelp   Forums   Help   Contact   Join   Order   Logon  
 
Home > Courses > Access > Seminars > Security > Lessons
Back to Security Seminar Lessons    Comments List
Upload Images   Link   Email  
Lesson 36 VBA problem
Victor Lugo 
      
3 years ago
On Lesson 36 @ 15:52, Richard shows us how to add changes recorded on a form using S as String and capturing the old values before updating the form.

I followed the instructions to a tee, but my syntax is not taking inside VBA. Please look at the uploaded picture.

Even when I remove the red lines completely, I'm still only getting one line of corrections into the 'Notes' section of my LogT.

Why is VBA recognizing one line but not another?
Victor Lugo OP 
      
3 years ago

Victor Lugo OP 
      
3 years ago

Victor Lugo OP 
      
3 years ago

Victor Lugo OP 
      
3 years ago

Adam Schwanz 
             
3 years ago
To start with, your first picture is just repeatedly changing S

Thats like saying
S=1
S=2
S=3
S=4

Now tell me what S is. S was a lot of things but at the end S = 4, all the rest of the stuff was useless.

If you want to add onto S, you can do
S=1 'So S = 1
S=S+1 'So S = 2
S=S+2 'So S = 4
S=S+3 'So S = 7
Now tell me what S is, and everything was useful, in the same way you can make strings, I think numbers are easier to understand though.

S="A"
S="B"
S would be B
S="A"
S=S+"B"
S would be AB
Adam Schwanz 
             
3 years ago
What I would do is make an oncurrent event and save those values to variables, I find it easier to read what I'm coding

Dim S, OldEnd, OldStart, OldLock
S = "Start=" & OldStart & " to " & Start
S = S & vbnewline & "End=" & OldEnd & " to " & End
S = S & vbnewline & "Lock=" & OldLock & " to " & Lock
Adam Schwanz 
             
3 years ago
Forgot the
OldEnd = End
OldStart = Start
OldLock = Lock

in the event
Victor Lugo OP 
      
3 years ago
@ Adam Schwanz, thank you for your help.
My problem is that I know just enough to be dangerous. I have been building on this project crawling and scraping along wherever I can find some good code to copy.
Basically, I do not know how to declare variables and properly structure a Dim statement from scratch. I usually find someone else's code useful and know just enough to replace their field and table names to suit my database.

So, with that being said, I think I understand what you're explaining with the
S=1
S=2
S=3
S=4
then only S=4 matters and the previous declarations were useless.

Victor Lugo OP 
      
3 years ago
Trying my best to figure out how to write out what you explained, but very limited to my syntax VBA coding knowledge, I came up with:

Dim S As String
S = "UIC: " & UIC
S = S & vbNewLine & "Event: " & EVENT
S = S & vbNewLine & "Avail: " & AVAIL
S = S & vbNewLine & "Start Date: " & START.OldValue & " to " & START
S = S & vbNewLine & "End Date: " & END.OldValue & " to " & END
S = S & vbNewLine & "Lock Date: " & LOCK.OldValue & " to " & LOCK

But man! It either just doesn't like that word "EVENT" or I can't figure out how to keep the code rolling on.

How did Richard get away with that in his video on Lesson 36?
Victor Lugo OP 
      
3 years ago

Scott Axton 
          
3 years ago
Victor - I'm going to scold here so feel free to scroll on by if you wish.

By your own admission above, you don't have the knowledge to be customizing this to your needs.
Some friendly advice here.  Stop what you are doing.  Set your project aside and go get the knowledge you need. Then come back to your project.

Sorry to be so blunt but when you say, "I do not know how to declare variables and properly structure a Dim statement" that raises all sorts of red flags to me.

It is a bit like me saying, "I've never driven a car before but today I'm going to just jump in, head to the freeway during rush hour, and learn."

You need to learn what those red lines mean.
You should be aware that you used reserved words as your field names.
You would have caught the fact that you didn't copy the syntax correctly.  ( S = S &   - above. )

Bottom line is were here to help but you are doing yourself a disservice by not getting at least the basics down first.

Victor Lugo OP 
      
3 years ago
@Scott Axton, appreciate your candor, but until you mentioned it, I did not realize I was using reserved words for field names.
That is helpful.
I found assistance in another forum.

Dim S As String
S = "UIC: " & Me!UIC.Value & vbNewLine
S = S & "Event: " & Me!EVENT.Value & vbNewLine
S = S & "Avail: " & Me!AVAIL.Value & vbNewLine
S = S & "Start Date: " & START.OldValue & " to " & Me!START.Value & vbNewLine
S = S & "End Date: " & Me!END.OldValue & " to " & Me!END.Value & vbNewLine
S = S & "Lock Date: " & Me!LOCK.OldValue & " to " & Me!LOCK.Value

Now my "LogIt" event was works just fine.
Adam Schwanz 
             
3 years ago
You could also have just bracketed the fields.

Instead of me!event.value just do [event]

But yea if this is a real database you are going to use and not just something your making for learning, go change those field names that are reserved they will give you tons of headaches later.
Victor Lugo OP 
      
3 years ago
@Adam Schwanz thanks!
I definitely understand what you and Scott are saying, but I'm afraid I can't put that Genie back in its bottle.
Once my upper management saw what I built just for me, it was directed to be made for other Users. Luckily for me, we're just a group of 8 Users, and although our database hosts thousands of records, it's not exactly mission essential. We were doing just fine before I built mine.
Anyways, I've been forced to build this plane as I'm flying it, so to speak, and I do all my experimentation with new features on a local copied database no one else has access to. This is why I'm grateful to have found this seminar and Richard's videos. Being able to release .accde versions to the others at my own pace has given me some breathing room.
As the saying goes, "Good enough for government work!"
Not sure if you've ever heard of that old and corny cliche, but what's terrifying is to know that it's true.
Richard Rost 
            
3 years ago
Glad you figured it out. I'd still go back and change your field names. End is a tricky reserved word to use. Trust me. 20 minutes of changing things now might save you hours a year from now.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Security Seminar Lessons.
 

 
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2025 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 1/23/2025 1:29:32 PM. PLT: 1s