How to do this...

  • Thread starter Thread starter vbken
  • Start date Start date
V

vbken

Guest
Hi,
I have a code like this:

RECORD = Table![Pre]

Pre is the name of a column. The question is, say I have a function that has a perameter Col. Col = "Pre". I tried doing this:
RECORD = Table![Col]
But that does not work. Does anyone know how I can vary the column name in the above code? I am trying to make my function more robust. Rather then making 5 or 6 functions that each use a different column in the table, I want to use one, and just vary the Col perameter.

Thanks
 
done by recordsets pse email for details
or see help in access
 
Option Compare Database
Option Explicit

Dim db As Database
Dim rs As Recordset


Set db = CurrentDb
Set rs = db.OpenRecordset("Query or Table Name")

With rs
tempVar = .Fields("Field or Column Name")
tempVar2 = .Fields("Next Field or Column Name")
tempVar3 = .Fields("You get the picture")
End With

Set rs = Nothing
 
with the code above, can you get the table name and the fields names from textbox,s on a form ? so it can be used with diffrent tables
 

Users who are viewing this thread

Back
Top Bottom