Re: runtime error with Mask edit control



1. This is copy and paste code. I wouldn't have retyped it. Notice the
indentation. That is also indented in the code, and pasted exactly as it
was cut.
2. The error is raised as stated in original message when mask edit control
(mebDOB) is filled with data from the database.
3. DateOfBirth property is a string. When read, it is formatted as
format(mstrDOB, "Short Date")
4. All underlying variables are strings
5. If no value is entered into the Property, the database stores a null.
6. GetMaskDate is a function that allows the mask to be set to an empty
string "", and then when the mask is needed it can be set correctly through
this function call. Note, ClearMaskControl and GetMaskDate work together.
7. DateOfBirth is stored in the database as a datetime value.
8. SQL will take the string values passed into the table and convert them
into the datetime type.


The problem again is when retrieving a date such as 01/01/2005, the value
being placed into the mask control as stored in the DateOfBirth property was
1/1/2005.
The error was being generated because the mask is ## / ## / ####.

Because the default value for the system short date format is m/d/yyyy, when
I change the system short date format to mm/dd/yyyy the error goes away.

I hope this helps clarify the issue.

WB

"MikeD" <nobody@xxxxxxxxxxx> wrote in message
news:%23cUuT2CsFHA.1172@xxxxxxxxxxxxxxxxxxxxxxx
>
> "WB" <none> wrote in message news:uLuGTZBsFHA.4072@xxxxxxxxxxxxxxxxxxxxxxx
> > Here is the code where the error gets raised.
> >
> > If .DateOfBirth <> "" Then
> > mebDOB.Text = .DateOfBirth
> > Else
> > Call ClearMaskControl(mebDOB)
> > mebDOB.mask = GetMaskDate
> > End If
> >
> > The DateOfBirth is a property of an employee object. It gets filled in
> > from
> > a call to the database. If there is a value in the database field then
> > the
> > property will have data. The data is returned as a string "mm/dd/yyyy".
> > Does that help you?
>
>
> You just posted enough code to raise more questions. <g>
>
> What is the line of code on which the error occurs? What is the data type
> of your DateOfBirth property and if it has an underlying variable, what is
> its data type (one would assume the same as the property, but you never
> know)? You said this property gets filled in if the field has a value. If
> there's no value in the database, is it a NULL (which would only be
possible
> if the data type is a Variant) or something else (like a 0-length string)?
>
> What is GetMaskDate? It's obviously a function, but what is the code for
it
> and what does it return (value and data type)? You said you were getting
an
> invalid property value error, correct? It's possible that whatever is
being
> returned by your GetMaskDate function is not a valid string that can be
> assigned to the Mask property. If so, this would have NOTHING to do with
> the system date format.
>
> When you say the data is returned as a string, exactly what are you
> referring to? Is the database field a string? What IS the data type of
the
> database field? You might even need to post your code which assigns a
value
> to your DateOfBirth property.
>
> IOW, you really haven't provided enough information to make much of any
kind
> of absolute determination as to why you're getting the error. There's
still
> a number of things it could be.
>
> Also, that is not copied and pasted code. You should always copy and
paste
> so that what you're posting is EXACTLY what you've written. Quite often,
> when you re-type the code, you inadvertantly "fix" whatever problem there
> was with the code as written in VB. I can tell it's most likely not
copied
> and pasted because "mebDOB.mask" should be "mebDOB.Mask" (VB would have
> automatically formatted the code to capitalize Mask, unless you have that
as
> another property/variable/function name elsewhere in your program written
as
> "mask").
>
> --
> Mike
> Microsoft MVP Visual Basic
>
>


.



Relevant Pages

  • Re: How to represent variable data types?
    ... double, integer, string, and timestamp. ... don't know the data type we're looking for. ... I'm working on refactoring the database this week, ...
    (comp.databases)
  • Re: Database datatype to c# datatype
    ... GetFieldTypeand GetValueon any IDataReader. ... because I get metadata about a database column: ... One of the items of data describing the column is a string value which gives ... the data type of the column. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Dynamic cast string value to a specific data type for stored procedure
    ... Robbe Morris - 2004-2006 Microsoft MVP C# ... I've mapped the database to .NET class properties and methods to ... - Stored procedure input parameters data type specific (SqlDbType.Int, ... I need a function that would grab the string value and dynamically ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: A little Rolodex [revised]
    ... including alpha sort and searching for any embedded string, ... In this application, a database is a directory, ... you may optionally provide any alternate UCASE program, ... NN -> first store NN as key length ...
    (comp.sys.hp48)
  • Re: return multiple rows from sql statement
    ... strings from input values is almost certainly a safe path to SQL ... Also, being a MySQL function, it knows what MySQL needs or uses. ... All characters that are entered in the fields make their way into the database unaltered. ... The insert of what surprisinlgly was NOT a syntax error, but a string called "mysql_insert_id" into an integer field resulted in the value zero being put in. ...
    (comp.lang.php)