Page 2 of 2 FirstFirst 12
Results 16 to 29 of 29
  1. #16
    mtengelh is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2015
    Posts
    15
    Thanks John...I got a data type mismatch error when I added the second command replacing the DoCmd. Not sure why that would be?

  2. #17
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    If Time and Date fields are Date/Time data type, parameters must be delimited with # not '.

    Should not use reserved words as names.

    If UserID is a number type, don't use any delimiters.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #18
    mtengelh is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2015
    Posts
    15
    Thank you for the comment I will definitely try the suggestion but this database was working previously as it was prior to the change to the combo boxes. I only added the combo boxes that tied the two fields together and the data will no longer populate in my table.

  4. #19
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    In your TaskTimings table, what is the data type of [TaskType]? If it is numeric, then as June7 points out, do not use single-quote delimiters around
    ComboTaskName.column(0).

    For the date, format and delimit it as shown, and you are left with:

    State = "INSERT INTO TaskTimings ([TaskType],[UserID],[TaskSubType],[Time],[Comment],[Date]) values (" & ComboTaskName.column(0) & ",'" & User & "','" & Status & "','" & Time & "','" & Comment & "',#" & Format(Date,"mm/dd/yyyy") & "#)"

    This assumes your field called [date] is date/time in your table, and I formated the date to ensure that it is in the format (US) that Access expects.

    BTW, as June7 also points out, you should not name table or form fields as "Date" or "Time". Although it does often work, especially if you use [] around the names, these should be considered reserved words and avoided as object and field names.

  5. #20
    mtengelh is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2015
    Posts
    15
    Thank you both for the assistance and suggestions. I made the suggested changes (see below). I still am receiving a syntax error (missing operator) in query expression.

    State = "INSERT INTO TaskTimings ([TaskType],[UserID],[TaskSubType],[Time],[Comment],[Date]) values (" & ComboTaskName.Column(1) & ",'" & User & "','" & Status & "','" & Time & "','" & Comment & "','#" & Format(Date, "mm/dd/yyyy") & "#')"
    CurrentDb.Execute State, dbFailOnError

  6. #21
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Remove the ' that precedes and follows #. Look closely at John's example.

    Also, if [Time] is a date/time type field, replace its ' delimiters with #.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #22
    mtengelh is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2015
    Posts
    15
    Thanks June...I removed both ' and still get the same message. [Time] is a text field

    State = "INSERT INTO TaskTimings ([TaskType],[UserID],[TaskSubType],[Time],[Comment],[Date]) values (" & Combo8.Column(1) & ",'" & User & "','" & Status & "','" & Time & "','" & Comment & "',#" & Format(Date, "mm/dd/yyyy") & "#)"
    CurrentDb.Execute State, dbFailOnError

  8. #23
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Try:

    Me.Combo8.Column(1)
    Me.User
    Me.Status
    Time()
    Me.Comment
    Date()
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  9. #24
    mtengelh is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2015
    Posts
    15
    Like this?

    State = "INSERT INTO TaskTimings ([TaskType],[UserID],[TaskSubType],[Time],[Comment],[Date]) values (" & Me.ComboTaskName.Column(1) & ",'" & Me.User & "','" & Me.Status & "','" & Time() & "','" & Me.Comment & "',#" & Date() & "#)"
    CurrentDb.Execute State, dbFailOnError

  10. #25
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Did it work?

    Why is [Time] a text field?

    Can still use the Format() function with Date() if the date structure is a concern. Review http://allenbrowne.com/ser-36.html
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  11. #26
    mtengelh is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2015
    Posts
    15
    The change did not work. I now get an error stating Compile Error : Method or data member not found

  12. #27
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Are those the names of the controls as well as the fields? Could try ! instead of dot or use the actual names of the controls.

    Me!User


    If you want to provide db for analysis, follow instructions at bottom of my post.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  13. #28
    mtengelh is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2015
    Posts
    15
    TimerNewv4.zip

    Attached is a copy for review.

    Thanks for the assistance

  14. #29
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Which form? Both of them have code for the INSERT action, but only one incorporates the suggested edits - it is the Timer form.

    The form is UNBOUND and the controls are UNBOUND. There are no fields to reference and no controls named ComboTaskName, User, Status. The names are Combo8, UserID, Combo20. Fix code or fix names.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Updating entries in combo boxes
    By Richard12 in forum Access
    Replies: 13
    Last Post: 02-17-2015, 02:09 PM
  2. Replies: 9
    Last Post: 04-04-2014, 03:30 PM
  3. Combo boxes incorrectly updating itself.
    By dylcon in forum Forms
    Replies: 1
    Last Post: 06-11-2013, 06:48 AM
  4. Trouble programming combo boxes
    By trolleri in forum Forms
    Replies: 6
    Last Post: 04-10-2013, 02:00 PM
  5. Cascading Combo Boxes trouble
    By Monterey_Manzer in forum Access
    Replies: 4
    Last Post: 09-13-2012, 11:06 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