-
Invalid Property Values
Hi, All!
I'm creating an Appt Schedule for a local hair salon.
Because of prior commitments, I had to put it on the shelf for 2 weeks. The owner of the hair salon said there was no problem.
I went back to it yesterday and even though it was working perfectly, up to that point, I'm now getting an "Invalid Property Value".
How do you fix something that was working before? There are no logical explanation for it!!
The offending line is marked with >>>>> <<<<<<. You can find it in the Case adDate after the Case adCurrency
Private Sub LoadMEControl(X As Integer, cFldName As String, cMask As String)
'-------------------------------------
' Load a Masked Edit control
'-------------------------------------
Dim sText As String
Dim aMask() As String
' This is an alternative to using the GetLocaleInfo() API
' to retrieve the decimal point character used on this machine:
Dim cLocalDec As String * 1: cLocalDec = Replace(Format(0, ".0"), "0", "")
If X > 0 Then
Load txtMEB(X)
End If
With txtMEB(X)
' Set some defaults; we may change these below
.Visible = True
.Mask = ""
.Format = ""
.ClipMode = mskExcludeLiterals
.PromptInclude = True
.CausesValidation = True
' -------------------------------------------------------
' Set the Left and Top positions. Height will not change.
' Width will be determined by the RecalcMaxWidth() sub
' in this form
' -------------------------------------------------------
.Move (Label1(0).Left + Label1(0).Width + 200), Label1(X).Top - 60
If oRst.EOF Then ' We're adding a new record
' When assigning Default string values under Access, Access adds
' surrounding quotes; we get rid of them here:
sText = Replace(oCat.Tables(Me.BaseTable).Columns(cFldName).Properties("Default").Value & "", """", "")
Else
If Not IsNull(oRst.Fields(cFldName).Value) Then
sText = Trim(oRst.Fields(cFldName).Value & "")
Else
sText = Replace(oCat.Tables(Me.BaseTable).Columns(cFldName).Properties("Default").Value & "", """", "")
End If
End If
sText = Replace(sText, vbCrLf, " ") ' There are peculiarities in the Customer table...
If cMask <> "" Then
' The "description" of the field may contain nothing, a Mask and/or
' a Format string. If both Mask and Format strings are to be assigned
' then they are separated by a pipe "|" character; for example:
' ##.##|99.99
' To skip the Mask and assign only a Format then store the following
' in the description of the field:
' |99.99
aMask = Split(cMask, "|")
.ClipMode = mskIncludeLiterals
.Mask = aMask(0)
.PromptInclude = False
If UBound(aMask) = 1 Then
.Format = aMask(1)
End If
.Text = sText
Label1(X).Tag = .Text
Else ' No mask was passed; let's try to figure out an appropriate one
Dim nFieldDataType As DataTypeEnum
nFieldDataType = oRst.Fields(cFldName).Type
Select Case nFieldDataType
''''''''''''''''''''''''''''''''''''''''''''
' Begin numeric values
''''''''''''''''''''''''''''''''''''''''''''
' These types do not allow decimal points:
Case adUnsignedTinyInt ' Byte
.Text = sText
.MaxLength = 3 ' 0-255
.Format = "0"
Case adSmallInt ' Integer
.Text = sText
.MaxLength = 6 ' -32,768 to 32,767
.Format = "0"
Case adInteger ' Long Integer
.Text = sText
.MaxLength = 10 '-2,147,483,648 to 2,147,483,647
.Format = "0"
' Don't mess with AutoNumber fields!
If oCat.Tables(Me.BaseTable).Columns(cFldName).Properties("Autoincrement") = True Then
' .Enabled = False
.Visible = False
End If
Case adNumeric ' Decimal
.Text = sText
sText = Replace(.Text, cLocalDec, ".")
.MaxLength = 10 ' +/-79228162514264337593543950335 (No decimal)
' +/-7.9228162514264337593543950335 with 28 places to the
' right of the decimal
' +/-0.0000000000000000000000000001 Smallest non-zero number
.Format = "0"
' These types allow decimal points:
' Single Double
Case adSingle
.Text = sText
sText = Replace(.Text, cLocalDec, ".")
.MaxLength = 10 ' -3.402823E38 to -1.401298E-45 for negative values;
' 1.401298E-45 to 3.402823E38 for positive values
Case adDouble
.Text = sText
sText = Replace(.Text, cLocalDec, ".")
.MaxLength = 10 ' -1.79769313486232E308 to -4.94065645841247E-324 for negative values;
' 4.94065645841247E-324 to 1.79769313486232E308 for positive values
Case adCurrency
.Format = "0.00"
.Text = Format(sText, .Format)
sText = Replace(.Text, cLocalDec, ".")
.MaxLength = 10 ' -922,337,203,685,477.5808 to 922,337,203,685,477.5807
''''''''''''''''''''''''''''''''''''''''''''
' End of numeric values
''''''''''''''''''''''''''''''''''''''''''''
Case adVarWChar ' Text fields
.Text = sText
.MaxLength = oRst.Fields(cFldName).DefinedSize
' .Move .Left, .Top, .MaxLength * m_nAvgWidth
Case adDate
Dim cLocalFmt As String: cLocalFmt = LCase(LocaleInfo(LOCALE_SSHORTDATE))
Dim cLocalSep As String: cLocalSep = LocaleInfo(LOCALE_SDATE)
.ClipMode = mskIncludeLiterals
.PromptInclude = True
.Format = LCase(cLocalFmt) ' will be, for example "mm/dd/yy"
cLocalFmt = Replace(cLocalFmt, "y", "#")
cLocalFmt = Replace(cLocalFmt, "m", "#")
cLocalFmt = Replace(cLocalFmt, "d", "#")
.Mask = cLocalFmt ' will be, for example "##/##/##"
>>>>>>>> .Text = Format(IIf(IsDate(sText), sText, Now), .Format)<<<<<<<<< sText = .Text .MaxLength = Len(.Text)
' .Move .Left, .Top, Me.TextWidth(String(Len(.Format), "9"))
' GUID
Case adGUID
' Don't mess with AutoNumber fields!
If oCat.Tables(Me.BaseTable).Columns(cFldName).Properties("Jet OLEDB:AutoGenerate") = True Then
.Enabled = False
End If
' Hyperlink or Memo field
Case adLongVarWChar
If oCat.Tables(Me.BaseTable).Columns(cFldName).Properties("Jet OLEDB:Hyperlink") = True Then
Else ' must be a memo field
End If
End Select
' If IsANumeric(nFieldDataType) Then
' .Move .Left, .Top, Me.TextWidth(String(.MaxLength, "9"))
' Else
' End If
End If
.SelStart = 0
.SelLength = Len(.Text)
.SelStart = 0
Label1(X).Tag = sText
End With
End Sub
I need to keep the Masked Edit control.
If anybody can help with suggestion, tips, it is you Guru's of All-Knowing Knowledge and Expertise.
I would really appreciate your help.
Thanks in advance,
vbprogwb
-
Do you have access to the system on which the error occurs? If so, I would set breakpoints and confirm that the cLocalFmt and .Mask properties are what you think they are.
Phil Weber
http://www.philweber.com
Please post questions to the forums, where others may benefit.
I do not offer free assistance by e-mail. Thank you!
-
I believe the "Guru's of All-Knowing Knowledge and Expertise" is someone who talks load at his/her cell sitting in the restaurant at the table besides you 
Usually something stops working only after something has changed, even though customers say the opposite (I did not do anything, just removed few keys from the registry...) I saw that your app deals with formatting using the current locale. Did someone changed the locale and/or the date or time formatting?
You get the error from ther exe or from the IDE? Can you see what are the .Text, sDate and .Format values at the time the error occours?
Marco
-
Invalid Property Values
Hi, mstraf & Phil!
Thanks for responding.
Case adDate
Dim cLocalFmt As String: cLocalFmt = LCase(LocaleInfo(LOCALE_SSHORTDATE))
Dim cLocalSep As String: cLocalSep = LocaleInfo(LOCALE_SDATE)
.ClipMode = mskIncludeLiterals
.PromptInclude = True
.Format = LCase(cLocalFmt) ' will be, for example "mm/dd/yy"
.Format - m/d/yyyy
LCase(cLocalFmt) = #/#/####
cLocalFmt = Replace(cLocalFmt, "y", "#")
cLocalFmt = Replace(cLocalFmt, "m", "#")
cLocalFmt = Replace(cLocalFmt, "d", "#")
All of these cLocalFmt = #/#/####
.Mask = cLocalFmt ' will be, for example "##/##/##"
.Mask = #/#/####
.Text = "Format(IIf(IsDate(sText), sText, Now), .Format)
.Text = " / / " (sText) = "" sText = "" .Format = m/d/yyyy
It ends here!
sText = .Text
.MaxLength = Len(.Text)
' .Move .Left, .Top, Me.TextWidth(String(Len(.Format), "9"))
"Do you have access to the system . . . "
I'm at home working on this project in my own spare time.
"Usually something stops working . . . . "
I'm the only one who has access to this project. It would have been on the shelf if it was possible to put it there.
"Did someone changed . . . ."
I'm the only one who uses this pc. By the way I'm using WinXP Pro.
"You get the error . . . ."
IDE
Feel free to ask any more questions.
Thanks for your help.
Thanks in advance,
vbprogwb
-
because your mask is #/#/####, that will work only in the first ten days of the first ten months (only one digit)
The mask and the format must agree, and the mask be at least ##/##/####
Marco
-
Invalid Property Value
Hi, Marco!
Is this what is causing the problem " #/#/####"? The lack of the extra pound signs?
Not sure what to look for on how to change LCase(cLocalFmt) = #/#/####.
Should I pay attention to "cLocalFmt = LCase(LocaleInfo(LOCALE_SSHORTDATE))"?
Or What?
Thanks in advance,
vbprogwb
-
what is LocaleInfo? I did not find it in the MSDN.
Marco
-
Invalid Property Value
Hi, Marco!
I got the answer from a member of the VISBAS-BEGINNERS@PEACH.EASE.LSOFT.COM
Change this line FROM:
Dim cLocalFmt As String: cLocalFmt = LCase(LocaleInfo(LOCALE_SSHORTDATE))
TO:
Dim cLocalFmt As String: cLocalFmt = "mm/dd/yy"
"what is LocaleInfo?"
I'm not sure myself, but I'm going to do some research.
When I find out I will give you a "buzz".
Later,
vbprogwb
-
 Originally Posted by vbprogwb
"what is LocaleInfo?"
I'm not sure myself, but I'm going to do some research.
you put code in your app that you do not know about? Quite of courage you have...
regarding the change to "mm/dd/yy", in doing that you force the user to enter the date in that format, instead of the one they selected for the current locale (and that maybe can be ok, depends in you)
Marco
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks