table naming conventions. help entering data.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tehgreatmg
    New Member
    • Jan 2007
    • 49

    table naming conventions. help entering data.

    I am drawing a complete blank on this. I want to enter data into a table just through VB code and not using text boxes. How are the individual cells/fields labeled in a table. The fields are "Model Number", months Jan-Dec, and "Total". So say I want to enter in 5 under the month January for the model that sits on row 3. How do I do this is it somethign like tablename.colum n,row = variable.
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32645

    #2
    Acess doesn't work in that way (unlike Excel). Unless you have a good reason, I would suggest that you do your data manipulation via the forms, provided in Access for that very purpose.
    If you must access records via VBA code, this tutorial (Basic DAO recordset loop using two recordsets) will give you a template from which to build.

    Comment

    • tehgreatmg
      New Member
      • Jan 2007
      • 49

      #3
      Thanks Neopa, Like I said I was drawing a complete blank, then it popped back into my head last night.

      Comment

      • tehgreatmg
        New Member
        • Jan 2007
        • 49

        #4
        I looked at that tutorial you posted and I am glad you showed me that. It is a lot easier than the way I was going to go about doing it.

        Comment

        • NeoPa
          Recognized Expert Moderator MVP
          • Oct 2006
          • 32645

          #5
          I would still recommend doing it via the forms themselves, however, I'm pleased you've got an answer that's good for you :)

          Comment

          • tehgreatmg
            New Member
            • Jan 2007
            • 49

            #6
            Well the whole thing is I am taking data from one table from a text box on a from, doing calculations with that data and data in a second table and writing the data back into the second table.

            Comment

            • tehgreatmg
              New Member
              • Jan 2007
              • 49

              #7
              Ok here is what I have right now. The problem I am having is with the NumOrdTotal = rs1!varLongMont h + Val(NumOrd) . I need to be able to define the field through a variable and open it up. Is it possible to do it somewhat like this and I am just missing something on the syntax or am I going to have to do and if or select statement saying || if varLongMonth = this then change this field || and do that for every record set?

              Code:
               Select Case varMonth
                      Case Is = 1
                          varLongMonth = "January"
                      Case Is = 2
                          varLongMonth = "Feburary"
                      Case Is = 3
                          varLongMonth = "March"
                      Case Is = 4
                          varLongMonth = "April"
                      Case Is = 5
                          varLongMonth = "May"
                      Case Is = 6
                          varLongMonth = "June"
                      Case Is = 7
                          varLongMonth = "July"
                      Case Is = 8
                          varLongMonth = "August"
                      Case Is = 9
                          varLongMonth = "September"
                      Case Is = 10
                          varLongMonth = "October"
                      Case Is = 11
                          varLongMonth = "November"
                      Case Else
                          varLongMonth = "December"
                  End Select
                  txttest = varLongMonth
              
                  Dim db As DAO.Database
                  Dim rs1 As DAO.Recordset
              
                  Set db = CurrentDb()
                  Set rs1 = db.OpenRecordset("Query_2")
                  rs1.MoveFirst
                
                  Do Until rs1.EOF
                      If rs1![ID] = Val(ID) Then
                          NumOrdTotal = rs1!varLongMonth + Val(NumOrd)
                          rs1.Edit
                          rs1!varLongMonth = NumOrdTotal
                          rs1.Update
                      End If
                      rs1.MoveNext
                  Loop
              
                rs1.Close
                Set rs1 = Nothing
                Set db = Nothing
              Sorry for the mess of code, I usually get it working then go through and organize it.

              Comment

              • NeoPa
                Recognized Expert Moderator MVP
                • Oct 2006
                • 32645

                #8
                Can you :
                1. Tell me where the last question ended and where the new one begins.
                2. Provide a title for the new thread.

                Then I can split this up into a new question.

                Comment

                • tehgreatmg
                  New Member
                  • Jan 2007
                  • 49

                  #9
                  Using a variable to identify a field. I moved it there and I think I have described my situation a little more clearly.

                  Comment

                  • NeoPa
                    Recognized Expert Moderator MVP
                    • Oct 2006
                    • 32645

                    #10
                    Nicely Done :)

                    Comment

                    Working...