Results 1 to 8 of 8
  1. #1
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    Easy VBA ideas (XP)

    Hi All

    I am just preparing a lesson plan for a lesson in Access tomorrow night. The section for this module is intro. to VBA. I have done this lesson some 10 times now and the University has provided me with the standard notes to produce the lesson plan. This class is very fast and bright and I have been slowly introducing some simple VBA examples( they don't need to go too deep in this module as the will be convering more indepth stuff later on if they wish) throughout the course and am running out of ideas for tomorrow.

    I generally provide them exercises that they can, say, produce a command button using the wizard, to open another form and then adapt it so they can close the curent form. Simple I know, but gets them the opportunity to get their hands dirty with out too much stress.

    Other ideas, and I know this is not really practical in the real world, is to produce a text box put =Now() in it and get it to refresh every second to produce a clock. They seem to like that. Having racked my brain for about an hour I thought I would ask you all if you have any ideas that I could use... no need for code, just ideas at this moment. Don't worry about time, I can pick them up any time tomorrow. Thanking you in advance..
    Jerry

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Easy VBA ideas (XP)

    Cascading combo boxes are a nice subject - mostly query and form design, plus a little bit of event code to requery a combo box. Useful in the "real world" too. See for example Basing one combo box on another.

    Another one is testing the value of a text box on a form in the Before Update event of that text box (set the Cancel argument to True if it doesn't meet certain criteria).

    Or make the detail section of a report display alternating background colors using the On Format event.

  3. #3
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Easy VBA ideas (XP)

    I like the Combo idea. I may use that as this will fit in nicely with part of their coursework.

    The third one with colour always gets them interested, I don't know why.

    No. 2 I will try and introduce to the more advanced in the clas

    All nice ideas

    Thanks Hans
    Jerry

  4. #4
    5 Star Lounger
    Join Date
    Nov 2004
    Location
    Wilmington, North Carolina, USA
    Posts
    1,196
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Easy VBA ideas (XP)

    <hr>The third one with colour always gets them interested, I don't know why.<hr>
    <img src=/S/whisper.gif border=0 alt=whisper width=29 height=17>Because they're suckers for a rainbow of colors and bad database design (not blaming their teacher, of course) <img src=/S/evilgrin.gif border=0 alt=evilgrin width=15 height=15>

    How about some of these?

    -Filter a listbox from textbox input (sometimes practical, sometimes not, nifty still)
    -Maybe just show them the GetNetUser module, just for S&G? That was awesome for me to find out.
    -Set form focus from listbox selection
    -Adding records from unbound form
    -Change visibility of text box based on first text box input
    -Select Case statements
    ____________________________
    Jeremy
    "If you spend more on coffee than on IT security, then you will be hacked. What&#39;s more, you deserve to be hacked." -Richard Clarke

  5. #5
    5 Star Lounger
    Join Date
    Apr 2003
    Location
    Hampshire, United Kingdom
    Posts
    602
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Easy VBA ideas (XP)

    Use the OnMouseMove event of a commandbutton to change the font attributes and the same event of the form itself to change them back.

    There's also the simple-but-powerful stuff, following on from the suggestion of showing them the GetNetUser module...
    I have a database with a table called "Boot", which has only one field, "UserName". The table is usually empty of data. In the switchboard form of the database, which is always open, I have the Timer Interval set to 10 seconds and the following in my OnTimer event:
    <hr>
    If Not IsNull(DLookup("UserName", "Boot", "UserName='" & GetNetUser & "' OR UserName = 'ALL'")) Then
    MsgBox "Sorry, you have been kicked out of the database so that important changes can be made." & _
    Chr(10) & "Please don't be offended!", vbCritical, "You've been booted"
    Application.Quit
    End If
    <hr>

    <img src=/S/evilgrin.gif border=0 alt=evilgrin width=15 height=15>

    I've got another table and a similar bit of code within the same OnTimer sub that acts as an instant messaging function, too.
    Waggers
    If at first you do succeed, you&#39;ve probably missed something.

  6. #6
    4 Star Lounger SteveH's Avatar
    Join Date
    Jan 2001
    Location
    Chelsea, Gtr London, United Kingdom
    Posts
    587
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Easy VBA ideas (XP)

    Following on from HansV's suggestion of cascading combo boxes, I would take one step back and get them to really understand how combo boxes work and their different flavours. That is probably the biggest problem that my students have - for example get them to create a search combo (option 3 on the wizard) - analyse the code created and then get them to synchronise the combo when you move through the records. This helps to introduce the concept of events and when they happen as well.

    Another good area for coding exercises is to create VBA validations in Before_Update events.
    Steve H
    IT Lecturer/Access Developer
    O2K SR3/O2010; Win7Pro

  7. #7
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Easy VBA ideas (XP)

    Thanks Steve

    The search combo is on my/our hands on exercises, I try and introduce it later into the VBA session as the me.Recordset.Clone of the code always seems to send the top of their heads spinning. Before_updates, yes like it, thank you.
    Jerry

  8. #8
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Easy VBA ideas (XP)

    How about this. Have them create a listbox and 2 buttons (an UP arrow and a DOWN arrow). Clicking the appropriate button will move the select line in the listbox Up or Down in the sequence. That is, selecting the last item in the listbox and then successively clicking the UP arrow would eventually move this item to the top of the list.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •