Results 1 to 2 of 2
  1. #1
    HeywoodJablowme
    Guest

    Using a module (a2k)

    Hi, I am a complete nerd when it comes to Acces but I am trying to learn as I go along.

    I copied the following module as a new module but I cannot get it to work (its supposed to change text to proper case). When I set up a new table do I have to tell it where to look for the module or should it automatically know because I have made sure that my table and field are the same as mentioned in the module.

    Option Compare Database

    Function GhFixCase()
    On Error GoTo Err1
    Dim SQL As String, Rs As DAO.Recordset, Db As DAO.Database
    Set Db = CurrentDb()
    SQL = "SELECT[tblCustomer].*FROM[tblCustomer]"
    Set Rs = Db.OpenRecordset(SQL, dbOpenDynaset)
    Do Until Rs.EOF
    Rs.Edit
    Rs![CustomerName] = StrConv(Rs![CustomerName], vbProperCase)

    Rs.Update
    Rs.MoveNext
    Loop
    Rs.Close
    Db.Close
    MsgBox "Done!", vbInformation, "Proper case!"

    Exit1:
    Exit Function

    Err1:
    MsgBox Err.Number & "" & Err.Description, vbInformation, "Proper case error..."
    Resume Exit1
    End Function

    I used the debug, compile feature which reported no errors.

    Any help would be very nice indeed, thank you

    Heywood

  2. #2
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Using a module (a2k)

    If you want to run the function once, open it in Design mode, put the cursor anywhere in the code and press F5.
    If you want to run it on regular base, then there are different possibilities.
    You can put a command button on a form and copy the code in the on click event of this button.
    If you use a switchboard, then you can run the code from a switchboard option
    Francois

Posting Permissions

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