Results 1 to 6 of 6
  1. #1
    Join Date
    Jul 2015
    Posts
    2

    Unanswered: Text Box Doesn't Display Data in Correct Format

    First post! Thanks to anyone who can help with this one. I have a ListBox that, when a record is clicked, populates a number of TextBoxes with the fields from that record so that the user can edit the information. One of these TextBoxes is populated with a payment amount. The field in the source table is set to Currency and the query that populates the ListBox doesn't alter the data type. The TextBox format is set to Currency but the data does not display that way. Any idea on how to fix this?

    Code:

    Private Sub Roster_Click() *******User clicks on name

    Dim mid As Integer

    'Get member id from selected row
    mid = Roster.Value

    'Populate PayHist with data
    strRst = "SELECT id, paydate As [Payment Date], payamt As [Payment Amt], nummths as [# Months], nextdate FROM Tbl_WaterPayments WHERE mbrid = " & mid & " ORDER BY paydate DESC;" ******payamt is the Currency field from the source table
    PayHist.RowSource = strRst
    PayHist.Requery

    'Populate PayName with data
    PayName.Value = Roster.Column(1)

    End Sub

    Private Sub PayHist_Click() ********User clicks on payment from history

    Debug.Print PayHist.Column(2)
    'Populate Edit Fields
    EditName.Value = Roster.Column(1)
    EditPayDate.Value = PayHist.Column(1)
    EditPay.Value = PayHist.Column(2) ***********This populates the TextBox in question
    EditMo.Value = PayHist.Column(3)
    EditNextDate.Value = PayHist.Column(4)

    End Sub
    Click image for larger version. 

Name:	TextBoxProb.PNG 
Views:	7 
Size:	42.7 KB 
ID:	16428

  2. #2
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    495
    Provided Answers: 24
    set the text box property format to 'currency'.
    The text box does not always obey the field property.

  3. #3
    Join Date
    Jul 2015
    Posts
    2
    The text box format is set to Currency. That's why I'm so confused... Everything seems to agree yet the data just doesn't display properly.

  4. #4
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    495
    Provided Answers: 24
    usu setting text box format to currency always works.

  5. #5
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    If I understand your problem correctly, formatting the Textbox as Currency will place the data on the right-hand side of the Control, but will not display the appropriate currency symbol, such as the dollar sign for the U.S. If this is the situation, set the Format of the Textbox to Currency, as ranman256 suggested, and in your code, change

    EditPay.Value = PayHist.Column(2)

    to

    EditPay.Value = "$" & PayHist.Column(2)

    substituting your currency symbol for the dollar sign, if different from the U.S. symbol.

    The problem is that Access tends to treat everything coming out of a Combobox/Listbox as Text.

    Linq ;0)>
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  6. #6
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    as MissingLinq suggests the issue is the value from a list/combo box is presumed to be text, so an alternative approach is to explicitly cast the value using the CCUR function. how that woudl worm if there was a nion numeric value, or a value that couldnt' be coereced into a number I dont' know
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

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