Setting a Variable to a Field in Table on OnChange property
Setting a Variable to a Field in Table on OnChange property
(OP)
I have a Form in which I want the OnChange property to run some VB code which sets a variable to a value from a Table
Thus I have something like
Dim variablehere as integer
set variablehere = DoCmd.RunSql "Select Field1 from Table1;"
The second bit doesn't work - can someone tell me the code that will set variablehere to Field1 (Note - there will only over be one record in Table1
Thanks for any help
Thus I have something like
Dim variablehere as integer
set variablehere = DoCmd.RunSql "Select Field1 from Table1;"
The second bit doesn't work - can someone tell me the code that will set variablehere to Field1 (Note - there will only over be one record in Table1
Thanks for any help
RE: Setting a Variable to a Field in Table on OnChange property
Dim variablehere as integer
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb()
Set rs = db.OpenRecordset("Table1")
With rs
variablehere = !Field1
End With
Set db = Nothing
John A. Gilman
gms@uslink.net