Results 1 to 5 of 5
  1. #1
    MunroeM is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2015
    Posts
    55

    Inputing data from one text box to another.

    Hello I have a form where the use will enter a new expiration date and fill in their name for tracking. I currently have them entering the new expiration date and name in two blank unbound text boxes. I attacked an image to help show what im trying to do.



    The "New Expiration Date" and "Updated By" sections in the Green box are the unbound text boxes these are where the user will enter their New expiration date and fill in their name.

    The Fields in the Red box are from the table "CalItemT". The Red Box is for Info only it can not be changed or even selected on this form. The Info Displayed here is dependent on the Serial Number Selected in the Blue Box.

    The Blue Box is the Serial Number of the Cal Item being updated. Its the Primary key field for the "CalItemT" table.

    When they click the Save and Exit button I want the "Previous Expiration" and Previous Updated By" data in the Red Box to be replaced with the "New Expiration Date" and "Updated By" Data in the Green box.

    I added Text to the Image to show Field names or text Box Names and what table they link to.

    I only have the Updated by section in the code right now as i figure i can just copy and paste and change a few names to get it to work for the new expiration date once i get it working.

    I tried using this code to do it but i get a 3144 Syntax error

    Code:
    Dim SQL As String
    SQL = "UPDATE CalItemT" & _
    "SET [CalItemT].[UpdatedBy] =  [Me.UpdateBy]" & _
    "WHERE SerialNum = Me.ComboboxSerNum "
    DoCmd.RunSQL SQL

    any help will be great.

    Even if you know of a different method for doing what i am trying to do suggest it and i will see if it will work for me

    Thanks
    Attached Thumbnails Attached Thumbnails Form.jpg  

  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,521
    Not sure I follow, but the form value needs to be concatenated into the string. Presuming it's numeric:

    Code:
    SQL = "UPDATE CalItemT " & _
          "SET [CalItemT].[UpdatedBy] =  [Me.UpdateBy] " & _
          "WHERE SerialNum = " & Me.ComboboxSerNum
    Note I also added spaces which may have caused a problem.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    It appears you are not keeping a history of cal dates since you are using "UPDATE" in the SQL, so try this (on a copy of the dB).

    Using Property Sheet/Other Tab/ Name property

    In the blue box:
    (ub = unbound)
    Rename the unbound control "NewExpDate" to "ubNewExpDate"
    Rename the unbound control "UpdatedBy" to "ubUpdatedBy"



    In the red box:
    (tb = text box)
    Rename the bound control "ExpirationDate" to "tbExpirationDate"
    Rename the bound control "UpdatedBy" to "tbUpdatedBy"



    Then, code for the button:
    Code:
        Me.tbExpirationDate = Me.ubNewExpDate
        Me.tbUpdatedBy = Me.ubUpdatedBy
        Me.Dirty = False
    
        Me.ubNewExpDate = Empty
        Me.ubUpdatedBy = Empty

  4. #4
    MunroeM is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2015
    Posts
    55
    Quote Originally Posted by ssanfu View Post
    It appears you are not keeping a history of cal dates since you are using "UPDATE" in the SQL, so try this (on a copy of the dB).

    Using Property Sheet/Other Tab/ Name property

    In the blue box:
    (ub = unbound)
    Rename the unbound control "NewExpDate" to "ubNewExpDate"
    Rename the unbound control "UpdatedBy" to "ubUpdatedBy"



    In the red box:
    (tb = text box)
    Rename the bound control "ExpirationDate" to "tbExpirationDate"
    Rename the bound control "UpdatedBy" to "tbUpdatedBy"



    Then, code for the button:
    Code:
        Me.tbExpirationDate = Me.ubNewExpDate
        Me.tbUpdatedBy = Me.ubUpdatedBy
        Me.Dirty = False
    
        Me.ubNewExpDate = Empty
        Me.ubUpdatedBy = Empty
    Perfect thanks the code made me realise what i was doing wrong befor when i was trying the same method you used. I was doing Me."name".Value = Me."othername"

    now it works like a charm

  5. #5
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Wonderful!!!

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

Similar Threads

  1. Replies: 10
    Last Post: 11-02-2015, 11:11 PM
  2. Inputting a form header
    By Lou_Reed in forum Access
    Replies: 1
    Last Post: 09-10-2015, 01:38 PM
  3. Replies: 7
    Last Post: 02-08-2014, 12:31 PM
  4. Inputing Checks
    By bornstein.a in forum Access
    Replies: 1
    Last Post: 08-27-2012, 04:29 PM
  5. Re-using a query by inputing date.
    By suverman in forum Queries
    Replies: 1
    Last Post: 05-31-2011, 09:33 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