Page 1 of 2 12 LastLast
Results 1 to 15 of 21
  1. #1
    Join Date
    Sep 2005
    Posts
    28

    Unanswered: How to set Text Type in the Textbox

    Hi
    VB Code:

    I create Textbox, how can I set the textbox to be Text/String Datetype?

    Please let me know, thanks.

    Thanks.

  2. #2
    Join Date
    Nov 2003
    Posts
    1,487
    If you want to ensure a value is string then try using:

    CStr(Me.MyTextBoxName)


    .
    Environment:
    Self Taught In ALL Environments.....And It Shows!


  3. #3
    Join Date
    Sep 2005
    Posts
    28
    Doesn't work.

    Since I created textbox, it involve date/name/amount input, the textbox will have 3 type, so when I click date, then change name, then it has error.

    How can I make the textbox handle 3 datatype?

    Thanks.

  4. #4
    Join Date
    Sep 2005
    Posts
    28
    This is a error message:


    The value you entered isn't for this field.

    For example, you may have entered text in a numeric field, or a number that is larger than the fieldsize setting permits.


    Since I choose date value, then change back name, so it has error.

  5. #5
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    by defintion a text box control's data type is string / text. You can store other datatypes in that control, and you can coerce other datatypes by setting an input mask or formatting rule.

    if you are altering a bound control then the input mask / validation rules applied are relevant to that underlying dtaa type in the database. From what you are saying I guess the problem is that the underlying datatype (from the table) and the formatting rule or input mask are in conflict.

  6. #6
    Join Date
    Sep 2005
    Posts
    313
    So, how can I set? Could you tell me?

    The textbox will handle Date,Amount,and Text. 3 Types. Could you tell me?

    I solved it for a long time. I am tired to work on this problem.

    Please help me.
    Thanks
    Thanks.

  7. #7
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    Sorry can't help, not without more detail

    The textbox will handle Date,Amount,and Text. 3 Types. Could you tell me?

    do you mean a composite display of 3 items concurrently
    selectign a differnet item depending on the values in the form
    perhgaps if you could give an example of what you are trying to achieve, with some sample data.

    Intrinsically a text box is always of type string, which is why you are usually reccomended to explcitily cast (convert) values from a control to a non string data type.

  8. #8
    Join Date
    Sep 2005
    Posts
    313
    My data is like that:

    I open the "Input" form
    there 2 textboxes
    search1 => Field name from Table
    value1 => value from the table depend on search1 name

    it is a filter.
    And, this form has "Input_sub" form, because I want to do filter.

    // this case is work well
    Case1:
    search1: Vendor Name
    value1: Amy
    //Do Again
    search1: Date
    value1: 8/31/2005
    //Do Again
    search1: Vendor Name
    value1: Jimmy
    ...


    // This case is Not OK, has error
    // this one is OK
    search1: Date
    value1: 8/31/2005
    // Do Again, Error come out
    search1: Vendor Name
    value1: Amy
    //Error message appear
    "The value you entered isn't valid for this field, For Example, you may have entered text in a numeric field or a number that is larger than the Fieldsize setting permits"

    Please give me the direction to solve this problem. I tried many ways, it still be there. I ever change the Datatype of date to be Text of the "Input" Table, then it works, but I want to use datatype of Date to be Date/Time.

    Please help.

    Thanks. Thanks a lot.

  9. #9
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    I'm not entirely certain I understand your explanation, but it looks like the porblem is being triggered by null values in your data stream.

    you may need to revise the assignment to of the values to the control to cater for null values

    This can be done by say using the iif() function or nz() function or isnull() function. These can also be used with the NOT predicate
    Last edited by healdem; 09-28-05 at 15:14.

  10. #10
    Join Date
    Sep 2005
    Posts
    313
    I mean that

    The textbox can handle 3 datatype input: Date (Date/Time), Vendor Name(Text), Amount(Currency).

  11. #11
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    It may be appropriate toi write a function to handle your formatting requirements

    I'd suggest create a function in a code module

    the prototype could be
    public function formatmystring(curAmount as currency, datPaydate as datetime, strDesc as string)
    formatmystring=""
    if not isnull(curAmount) then formatmystring = formatmystring & format(curamount,"#,##0.00p ") & ";"
    if not isnull(datpaydate) then formatmystring = formatmystring & format(datpaydate,"dd-mmm-yyyy @ HH:MM") & ";"
    if not isnull(strDesc) then formatmystring = formatmystring & strDesc
    end function

    and then call that function in each contol you want to display the information set the value =formatmystring(var1,var2,var3)

  12. #12
    Join Date
    Sep 2005
    Posts
    313
    Doesn't work. It's hard to solve that.
    I think that I cannot solve this problem.
    Anyway, thanks a lot. Thanks. Thanks.

    My question is:
    //combox
    Search1 value1
    Date 8/31/2005 => do filter

    Search1 value1
    Name Jimmy => Cannot do filter, Error message

    Okay, you can try to do it in the table, create the new table, make one field to be Date (Date/Time), after that input the Character, the error message will come out, that message is what I said before. Now, I can set Text for Date, and then set Input Mask, but actually, I don't like it, because it fix the position, I want to set Date/Time, because it is automatic come out the date format if I just 8/31/05, it will come out 8/31/2005 automatically. And also, the if the Amount set Text, it doesn't have xx,xxx.xx, this format. There are too many problems since I make the filter which filter can search any field and any value. The datatype will change always. That's why I cannot solve. Anyway, thanks a lot. Thanks. Thanks.

  13. #13
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    Should work, in waht way did it fail to meet your requirements? or fall over

  14. #14
    Join Date
    Sep 2005
    Posts
    313
    what is var1 and var2 and var3

    I only input one value each time.

  15. #15
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    var1 is the name of your currency field say called myCurVal
    var2 is the name of your date field say called myDateVal
    var3 is the name of your desc field say called myDescVal

    so if you have all 3 fields
    =formatmystring(myCurVal,MyDateVal,myDescVal)

    alternatively you could rewrite the function as:
    public function formatmystring(objValue as variant, bytStyle as byte)
    formatmystring=""
    if bytStyle=1 and not isnull(curAmount) then formatmystring = formatmystring & format(curamount,"#,##0.00p ") & ";"
    if bytStyle=2 and not isnull(datpaydate) then formatmystring = formatmystring & format(datpaydate,"dd-mmm-yyyy @ HH:MM") & ";"
    if bytStyle=3 and not isnull(strDesc) then formatmystring = formatmystring & strDesc
    end function

    the advantage of this approach is that you can tell the fucntion what value you are formatting

Posting Permissions

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