INSERT Value into table after update. single value INSERT

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gcoaster
    New Member
    • Sep 2007
    • 117

    #1

    INSERT Value into table after update. single value INSERT

    Hello Gurus,
    I am stuck! this will be easy I am sure for you.

    I have a Text Box where I type In a name.
    I am trying to get that value to insert into another table when I TAB to the next field.

    Most of the INSERT code examples I find deal with multiple VALUES.
    could you point me in the right direction?


    thank you!
  • HiTechCoach
    New Member
    • Nov 2007
    • 30

    #2
    In the After update event, I would use an Append query to Insert the the record.

    Something like:

    Code:
    CurrentDB.Execute "Insert into tblYourTable (Field1) Values('" & Me.TextBoxControl & "')"


    Originally posted by gcoaster
    Hello Gurus,
    I am stuck! this will be easy I am sure for you.

    I have a Text Box where I type In a name.
    I am trying to get that value to insert into another table when I TAB to the next field.

    Most of the INSERT code examples I find deal with multiple VALUES.
    could you point me in the right direction?


    thank you!

    Comment

    • gcoaster
      New Member
      • Sep 2007
      • 117

      #3
      oh man.. You guys ROCK! !
      IT WORKS!! sorry, I spent 3 hours trying to figure it out and to see it work kinda was exciting..

      Code:
      Private Sub txtBoxName_AfterUpdate()
      CurrentDb.Execute "Insert into tblNames (firstName) Values('" & Me.txtBoxName& "')"
      End Sub

      Comment

      • gcoaster
        New Member
        • Sep 2007
        • 117

        #4
        ok.

        INSERT inserts a new value and RECORD when txtBoxName is updated or if modified.

        How doI write code to update if there is already a value?

        thank you

        Comment

        • HiTechCoach
          New Member
          • Nov 2007
          • 30

          #5
          How will you know wich record to update?

          You will need to someway identify the record by something unique like the Primary key.

          I normally do not do this. I would just insert an additional transactional record.

          If we know what you are trying to do, we will be able to help you find the best solution.

          What are you trying to accomplish?

          Comment

          • gcoaster
            New Member
            • Sep 2007
            • 117

            #6
            I have a field in a subform that i want to update with what is entered in the main form.

            table 1 is bound to fmMAIN and Table2 is bound to fmMAINsub

            when I enter domain text into domain field in Table1 I need code that udpates in the afterUpdate and inserts into the domainName column in Table2 or udpdates if text is changd. and maybe in another field in a table in the database

            TABLE1
            webID
            clientFK
            domain

            TABLE2
            webDetails
            webFK
            clientFK
            domainName

            Comment

            • MMcCarthy
              Recognized Expert MVP
              • Aug 2006
              • 14387

              #7
              Sorry to butt in, but this sounds like you are duplicating information for domain in both tables. If not then I don't understand what you are doing.

              Comment

              • gcoaster
                New Member
                • Sep 2007
                • 117

                #8
                Hello mmccarthy!!
                You can butt in anytime you like princess!

                Mary, I have just learned vba in the last 2 months and had a time figuring it out.
                I am still having a hard time wording things properly. like for instance, 2 months ago questions and searches about
                "cascade combo boxes" where worded
                "filtering results from dropdown"

                here was the solution to my problem

                This code is getting email address from combobox in column 3 and populating
                field on form named clientEmail.

                Code:
                Private Sub cboFullName_AfterUpdate()
                Me.clientEmail = Me.cboFullName.Column(2)
                End Sub
                I have learned you can bring in more then 2 values using wizard for combobox on a main form and then use those values from it to populate textboxes on forms etc one of the many tricks i have learned on here.

                thank you very much and may the Lord bless you this Christmas
                gcoaster

                Comment

                Working...