Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

expand caps format procedure to end user

Status
Not open for further replies.

Donkeygirl

Technical User
Nov 30, 2000
52
US
I have this code, and it is used on click of a form to make a table with all capital letters, become proper case. This means that BOB SMITH, with BOB in a first name field, and SMITH in the last name field, becomes Bob and Smith. This is really helpful for some of the data that comes through our office.

Right now, I am trying to take the procedure and make it so that it will ask the user what table they want to format, and what fields in the table they want to format. This would make the procedure easy for anyone in the office run, and it would make it run faster for me. I am wondering if anyone can help me expand this code to do that.
Thank you in advance

Option Compare Database

Function ghFixCase()
On Error GoTo Err1
Dim SQL As String, Rs As Recordset, Db As Database
Set Db = CurrentDb()
SQL = "SELECT [MCDC Weighted Count].* FROM [MCDC Weighted Count]"
Set Rs = Db.OpenRecordset(SQL, dbOpenDynaset)
Do Until Rs.EOF
Rs.Edit
Rs![City/towns] = StrConv(Rs![City/towns], vbProperCase)
Rs![LAST NAME] = StrConv(Rs![LAST NAME], vbProperCase)
Rs![FIRST NAME] = StrConv(Rs![FIRST NAME], vbProperCase)
Rs![STREET] = StrConv(Rs![STREET], vbProperCase)
Rs![POSTAL ZONE] = StrConv(Rs![POSTAL ZONE], 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 hope someone can help :) Donkeygirl,
Kickin' the crap out of Access
 
Create a table with a list of tables and their field names. Create a form with a sub form. On the form you would have a combo box which uses the table you just created as a source. On the sub form you would have a series of check boxes,all set to invisible (along with their labels.) you would select the table with the combo box. when you click the button on the form, you would open a recordset of that table where the tablename equals the combo box. loop through the records, picking up field names and use them to set the lable caption for the first check box label, the name of the first check box and make them both visible.

The sub form will now show the names of the fields along with the check box. The operator would select the fields to be modified and press another button (or the same button if you want to code it to recognize which click it is getting - the first or the second). This would run your code with which selects the table from the form and then selects the fields to be modified by using IF statements which check the state of the corresponding check box.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top