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.
table naming conventions. help entering data.
Collapse
X
-
Tags: None
-
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. -
Thanks Neopa, Like I said I was drawing a complete blank, then it popped back into my head last night.Comment
-
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
-
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
-
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?
Sorry for the mess of code, I usually get it working then go through and organize it.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 = NothingComment
-
Using a variable to identify a field. I moved it there and I think I have described my situation a little more clearly.Comment
Comment