Table & Feild Refenece in VBA

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

What is the format for referencing a specific field in a table? I tried it
as written below (substituting my field and table names), but it does not
work (with or with out the quotes)... see below.

Do I need to somehow declare the table and fields?

Thanks,

Nick
 
If I am correct in thinking what you want to do you will have to select the
record from the table and then do your comparison

Set dbs = OpenDatabase("C:\database.mdb")
QrySel = "Select fieldname from table As SpecificField where
whateverconditions"
Set RstSel = dbs.OpenRecordset(QrySel, dbOpenDynaset)
On Error GoTo Errorwhatever
RstSel.MoveFirst
( Here you can use the field for example:
If TbxName.Value = RstSel!SpecificField then
do condition
End If
RstSel.Close )
 
Back
Top