Base form uppercase

I had used the “when changed” (everything else like you show above) before I read your latest comment. In both cases I receive an error (actually the error is repeated 4 times) – Basic syntax error, syntax error.

@JoeCastor Please post the first three lines of the code used which includes the line with Sub.

Here they are:

   Sub UPPER_case (oEvent As Object)  
       oTextBox = oEvent.Source.Model
   sText = Ucase(oTextBox.Text)

Sorry, I can’t get the last two lines to go into the code box.

Cannot see why you are getting a syntax error! Pasted your code over mine & worked without a problem. Without access to what you have, created an alternative. Took an old embedded copy of yours and stripped it down to essentials but still a working copy. Please note I have added two lines to the macro - wasn’t exactly acting as wanted. Hopefully this sample will locate where you are having the problem. Will add file to main answer.

Ratslinger, I found the following code and it seems to work fine.

Sub UPPER_case ( oEv as variant ) 

oEv.Source.Text = UCase( oEv.Source.Text )

End Sub

Joe

Modify or add an record using lowercase. After entering, look at the record in MemberMaster. Lowercase? Try the routine I sent in the sample. If you get an error, just remove As Object in first line. Work now?

No. Still Basic syntax error on second line: I removed the AS object with and without the parens.

 oTextBox = oEvent.Source.Model

Is that the sample execution? One last thing to try - change Object to variant. It really doesn’t make any sense. All works fine on my system - tried in three different Base files.

I made change as indicated. Still get Basic syntax error. Here is the full script of the macro:

Sub UPPER_case (oEvent AS variant)

oTextBox = oEvent.Source.Model
sText = Ucase(oTextBox.Text)
oTextBox.setString(sText)
End Sub

Based upon your last comment this is not from the sample posted. Did you actually run the sample .odb with the macro it came with? No mods, no copy. Just test the sample.

I’m having trouble posting what I have in the macro library. I’ll post in as first half then second:

Sub UPPER_case (oEvent As variant) 'Text Box > Events > When Losing Focus 

oTextBox = oEvent.Source.Model
sText = Ucase(oTextBox.Text)
oTextBox.setString(sText) 'same effect as .BoundField.updateString() below
’ oTextBox.BoundField.updateString(sText) 'same effect as .setString() above

’ oForm = oTextBox.Parent 'these 3 lines combined will immediately save the record…
’ oForm(oTextBox.Name).commit()
’ IF oForm.isnew THEN oForm.insertRow() ELSE oForm.updateRow()
End Sub

Just want a simple test of the sample posted in my answer. Does that work or not. That is all I’ve been looking for since posting it. Not sure if you ever gave the answer.

Not referring to the Macro but the .odb I posted.

I went back to the second comment in this now long list of comments and recopied the macro, pasted it into the macro editor and every thing remained the same, still Basic syntax error

Please, let’s get on the same page. In my answer, on the very last line there is a posted sample of SASMemberMasterMacro.odb. Please download this sample and test the last name.

I downloaded the file “Macro Sample.” I ran the macro in the DB you included and it worked. I copied the macro to the split DB and it didn’t give the error. I opened the Form and change the text field to lower case. The field changed to upper case. I then checked the table and all is a expected. Thank you. Finally. Sorry for all the confusion on my part. This got a bit confusing for me. Again, thank you for your help. Is the macro in the “Sample Macro” good to use as it is?

YEAH! Yes, the macro is basically the same as where you started with the addition of two lines. Those two lines cleared up a display problem & a posting problem. You should be good to go with that code. Still don’t understand why you were getting that syntax error. If you look, the same line is in this code.

YEAH! from me too. Thank you for your patience. On to the next project. Hopefully I won’t be such a PITA on the next one.