Invoking Table/Query cells in VBA (1 Viewer)

Heron

New member
Local time
Today, 03:39
Joined
Feb 4, 2002
Messages
8
How does one invoke, call up or insert the name of a table cell or query cell in a VBA routine. Is it
.[cell]; or table.cell; or table!cell or what. Thanks.
 

anna the third

Registered User.
Local time
Today, 03:39
Joined
Sep 17, 2001
Messages
14
it's fields

e.g.
Retrieve Name of your column

CurrentDb.TableDefs("T1").Fields(0).Name
OR
CurrentDb.TableDefs("T1").Fields("ID").Name

gives in this case, as result "ID"

For the value use
CurrentDb.TableDefs("T1").Fields(0).Value
OR
CurrentDb.TableDefs("T1").Fields("ID").Value

anna
 

Heron

New member
Local time
Today, 03:39
Joined
Feb 4, 2002
Messages
8
Thanks, Anna, for your prompt response. Sorry if I appear dumb, but this is my first VBA day although I have two year’s experience in designing in Access 2000 the conventional way (tables, queries etc). I tried the code below incorporating your suggestion and it locked on the very first line. I want to get values (integers) from fields M1-M12 in Table “tB” and display them in TextBoxes “Jan – Dec”on a form. What is wrong with my code, please?
Unfortunately, all the books I’ve seen do not make it very clear which are reserved commands and which are just names. Also, do you need to Dim a value if the value type has already been declared in a table?

I need to bill monthly on within X period and within Y budget. Later I will do calculations on them with quite a bit of logic and itineration (carrying balances forward) and lots of date manipulation. THEN I need to get data OFF the Module and onto other tables or queries maybe.

By the way, the reason why I am plunged suddenly into VBA is that every time I try to do a lot of itineration combined with logic statements in a query I get the error “Query is too complex” (Error #3360) I’ve posted questions about this but never got a response. I’ve given up trying to use queries for this section of the database.

I wrote:-

Option Compare Database
Private Sub Form_Load()

Dim CurrentDb.TableDefs("tb").Fields("M1").Value as integer ‘January Input
Dim CurrentDb.TableDefs("tb").Fields("M2").Value as integer ‘February Input
Repeat until Field M12 incl.

For fc = 1 To 12
M(fc)= TextBox M(fc)

Next M(lc)

End Sub
 

Users who are viewing this thread

Top Bottom