frustrating

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • chembuff1982
    New Member
    • Mar 2007
    • 27

    frustrating

    I still am having trouble passing a value to a field in a table.

    It's all one database in access. I have my form, tables etc. They filter to combo boxes. Than I sent the value to a text box like someone told me. That works fine. I now want the textbox to send to my field in the table.

    I just need an example of how to send, from a textbox on a form, to a cell in a table. Let's make the textbox (mytextbox) and the cell in the table (mycell) and the table (mytable). I just want a basic example with that if possible. I can figure out the rest from there. I pretty much am asking how to make the source of my cell the textbox value. That's all I need to know. It might not even require vigorous programming in visual basic.
  • developing
    New Member
    • Mar 2007
    • 110

    #2
    properties> Data (tab)> control source

    ?

    Comment

    • nico5038
      Recognized Expert Specialist
      • Nov 2006
      • 3080

      #3
      I get the impression you're on the "wrong track".
      The getting data from (one or more) fields from a table into a form's textbox is OK, but storing such a value is asking for trouble.

      The "normalized " way in cases like this is to use the same construction as for filling the textbox in a query, thus amking sure that the data is accurate.

      Getting the idea ?
      When not, please explain in more detail where the texbox data is coming from and why you want to store it.

      Nic;o)

      Comment

      • chembuff1982
        New Member
        • Mar 2007
        • 27

        #4
        Sorry about that I figured it out the other day. My program is pretty complex so it gets confusing at times. I'm programming a complete database for a lab with drop down menu selections, bench sheets, records etc. I defined a string

        strCustomer well I'll show you my code I got it working most of the way.



        Private Sub cmdprint_Click( )
        On Error GoTo Err_cmdprint_Cl ick









        Dim stDocName As String
        Dim MyForm As Form



        stDocName = "tbldate"
        Set MyForm = Screen.ActiveFo rm
        DoCmd.SelectObj ect acTable, stDocName, True
        DoCmd.PrintOut
        DoCmd.SelectObj ect acForm, MyForm.Name, False
        Text54.Value = Now()
        Text54.Visible = True





        Exit_cmdprint_C lick:
        Exit Sub

        Err_cmdprint_Cl ick:
        MsgBox Err.Description
        Resume Exit_cmdprint_C lick
        End Sub

        Private Sub Combo27_AfterUp date()
        Dim rs As Object
        Set rs = Me.Recordset.Cl one
        rs.FindFirst "[CompanyID] = " & Str(Nz(Me![Combo27], 0))
        If Not rs.EOF Then Me.Bookmark = rs.Bookmark
        Me.Combo29.Requ ery
        Combo29.Visible = True



        End Sub


        Private Sub Combo27_Change( )
        cmdprint.Visibl e = False
        Dim strCustomer As String

        ' define string

        strCustomer = strCustomer & "" & Me.Combo27.SelT ext & ", "

        'appending the value to string from box


        ' remove excess off string in append
        strCustomer = Left(strCustome r, Len(strCustomer ) - 2)
        pass (strCustomer)





        End Sub






        Private Sub Combo29_AfterUp date()
        cmdprint.Visibl e = True

        End Sub





        Private Sub Combo29_Change( )

        Dim strTest As String ' define string Test to use for append

        strTest = strTest & "" & Me.Combo29.SelT ext & ", " 'append string from combobox


        ' to remove excess comma stored in append
        strTest = Left(strTest, Len(strTest) - 2)
        pass2 (strTest)

        cmdprint.Visibl e = True
        End Sub



        Private Sub Form_Load()
        Text54.Visible = False
        Combo29.Visible = False
        cmdprint.Visibl e = False





        End Sub



        Sub pass(x As String)

        Dim store As String

        store = x
        If cmdprint.Visibl e = True Then



        Dim strSQL As String

        strSQL = "INSERT INTO TablePrint (CustomerPrint) " & _
        "VALUES('" & store & "')"
        DoCmd.RunSQL strSQL


        DoCmd.GoToRecor d , , acNewRec
        End If







        End Sub
        Sub pass2(y As String)
        Dim store2 As String
        store2 = y
        If cmdprint.Visibl e = True Then

        Dim strSQL As String




        strSQL = "INSERT INTO TablePrint (CustomerTest) " & _
        "VALUES('" & store2 & "')"
        DoCmd.RunSQL strSQL


        DoCmd.GoToRecor d , , acNewRec

        End If
        End Sub

        Comment

        Working...