Getting the value of a field

  • Thread starter Thread starter gg
  • Start date Start date
G

gg

I am working with a form and moving the focus to certain
fields based on other factors using VBA. How do I get the
value of that field so that I can use it in other
calculations? It must be simple, but I can't find it.

Example.
Identifier 1stheader 2ndheader 3rdheader etc.
alpha 1 4 5
bravo 3 5 6
charlie 5 8 9
etc.

Depending on the outcome of other calcs, I might want to
move to Bravo and get the value of 2ndHeader. I can get
there, but don't know how to extract the value

Can someone recommend a book for access vba. I have the
step by step book, but it is hard to use as a reference,
more of a course book.
 
To find the value of the 2ndHeader field in the form, where Identifier is
"Bravo":

With Me.RecordsetClone
.FindFirst "[Identifier] = ""Bravo"""
If .NoMatch Then
MsgBox "Not found"
Else
MsgBox "2ndHeader is" & !2ndHeader
End If
End With

Notes:
1. If the Identifier is a Number type field, drop the extra quotes, e.g.:
.FindFirst "[Identifier] = 99"

2. It might be easier to lookup the value in the table the form is based on:
DLookup("2ndHeader", "MyTable", "[Identifier] = ""Bravo""")
For help with DLookup(), see:
http://users.bigpond.net.au/abrowne1/casu-07.html
 
Back
Top