I created a table (named: tbl_x) using microsoft access 2003
tbl_x contains n fields; namely fld_1, fld_2, .... fld_n.
I wrote a code to a recordset as follows:
---------------------------------------------------
Function disp_field()
'declare variables
Dim var_fieldname as fields, rst as recordsets
var_fieldname = Inputbox("Key in the field name.")
sqltxt = " Select tbl_x.var_fieldname FROM tbl_x;"
Set rst = CurrentDb.OpenRecordset(sqltxt)
rst.MoveLast
rst.MoveFirst
x = rst.RecordCount
MsgBox "The field contains " & x & " records."
End Function
-------------------------------
When run, the error msg is:
Runtime error 91
Object varialbe or With block variable not set
Please help. Thx.