By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,493 Members | 1,179 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,493 IT Pros & Developers. It's quick & easy.

table naming conventions. help entering data.

P: 49
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.column,row = variable.
Feb 14 '07 #1
Share this Question
Share on Google+
9 Replies


NeoPa
Expert Mod 15k+
P: 31,186
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.
Feb 14 '07 #2

P: 49
Thanks Neopa, Like I said I was drawing a complete blank, then it popped back into my head last night.
Feb 15 '07 #3

P: 49
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.
Feb 15 '07 #4

NeoPa
Expert Mod 15k+
P: 31,186
I would still recommend doing it via the forms themselves, however, I'm pleased you've got an answer that's good for you :)
Feb 15 '07 #5

P: 49
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.
Feb 15 '07 #6

P: 49
Ok here is what I have right now. The problem I am having is with the NumOrdTotal = rs1!varLongMonth + 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?

Expand|Select|Wrap|Line Numbers
  1.  Select Case varMonth
  2.         Case Is = 1
  3.             varLongMonth = "January"
  4.         Case Is = 2
  5.             varLongMonth = "Feburary"
  6.         Case Is = 3
  7.             varLongMonth = "March"
  8.         Case Is = 4
  9.             varLongMonth = "April"
  10.         Case Is = 5
  11.             varLongMonth = "May"
  12.         Case Is = 6
  13.             varLongMonth = "June"
  14.         Case Is = 7
  15.             varLongMonth = "July"
  16.         Case Is = 8
  17.             varLongMonth = "August"
  18.         Case Is = 9
  19.             varLongMonth = "September"
  20.         Case Is = 10
  21.             varLongMonth = "October"
  22.         Case Is = 11
  23.             varLongMonth = "November"
  24.         Case Else
  25.             varLongMonth = "December"
  26.     End Select
  27.     txttest = varLongMonth
  28.  
  29.     Dim db As DAO.Database
  30.     Dim rs1 As DAO.Recordset
  31.  
  32.     Set db = CurrentDb()
  33.     Set rs1 = db.OpenRecordset("Query_2")
  34.     rs1.MoveFirst
  35.  
  36.     Do Until rs1.EOF
  37.         If rs1![ID] = Val(ID) Then
  38.             NumOrdTotal = rs1!varLongMonth + Val(NumOrd)
  39.             rs1.Edit
  40.             rs1!varLongMonth = NumOrdTotal
  41.             rs1.Update
  42.         End If
  43.         rs1.MoveNext
  44.     Loop
  45.  
  46.   rs1.Close
  47.   Set rs1 = Nothing
  48.   Set db = Nothing
  49.  
Sorry for the mess of code, I usually get it working then go through and organize it.
Feb 15 '07 #7

NeoPa
Expert Mod 15k+
P: 31,186
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.
Feb 15 '07 #8

P: 49
Using a variable to identify a field. I moved it there and I think I have described my situation a little more clearly.
Feb 15 '07 #9

NeoPa
Expert Mod 15k+
P: 31,186
Nicely Done :)
Feb 15 '07 #10

Post your reply

Sign in to post your reply or Sign up for a free account.