Results 1 to 6 of 6
  1. #1
    injanib is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jan 2011
    Posts
    67

    Adding values in a table with unbound fields on the form

    Hello and thanks for any help in advance.

    I have a continuous sub-form based on a table. The form is disabled, and used only for displaying records. I have unbound fields at the bottom of the main form that I enter data into and then write the data in the underlying table for the sub-form by pressing a button. The reason I do this is to avoid the problems associated the subform saving data when losing focus, etc.

    So, before I write the data from the unbound fields into the table, I would like to check for its data type so that I don't run into data type mismatch with the data type of the fields in the table.

    One of the unbound field must have currency data type, another date data type,
    and the other is just text and number fields.

    for the number field I just use the (if Not IsNumeric then), which works perfect. How can I check the others?



    I don't want to use the built-in Input Mask, because I want to avoid the default Access pop-up message that is associated with the input mask.

    Hope there is a good solution for it.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,529
    You can use IsDate() for the date. The currency field is just a number, so IsNumeric() will work for it.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    injanib is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jan 2011
    Posts
    67
    Thanks for the quick response. Is there any way to have ignore the format of the fields?
    For example, when I enter a number in the field for currency, it is formatted to show the currency symbol in front of it. When it tries to write it to the table, it looks at the currency sign and since the field in the table is currency, it gets confused and gives me a message for the data type convention. I use the following code to write the data in the table.

    Set rst = CurrentDb.OpenRecordset("tblPayroll")
    With rst
    .AddNew
    !Amount = Me![txtAmount]
    !DateReceived = Me![txtPaymentDate]
    !Term = Me![txtPaymentTerm]
    !Memo = Me![txtMemo]
    !StaffID = Me![txtStaffID]
    .Update
    .Close

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,529
    I'm confused, because a currency data type doesn't actually store the currency symbol, it just stores the numeric value. What is the user actually entering in your textbox?

    123

    or

    $123

    I do the type of thing you're doing all the time and I only check IsNumeric for currency fields.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    injanib is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jan 2011
    Posts
    67
    The user enters 123, but after the update the unbound text field is formatted to show $123 with a code.

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,529
    Can you post the db? You shouldn't get a mismatch, and I can't duplicate the problem.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 0
    Last Post: 03-08-2011, 05:56 PM
  2. Replies: 4
    Last Post: 12-03-2010, 04:05 PM
  3. Look up values in multiple table fields
    By nmcentire in forum Programming
    Replies: 2
    Last Post: 11-12-2010, 02:02 PM
  4. Adding Sequential Values to Make-Table Query
    By obrien.robj in forum Queries
    Replies: 2
    Last Post: 08-25-2010, 12:55 PM
  5. Replies: 1
    Last Post: 10-09-2009, 11:52 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums