referencing a bound form's recordset w/o a control

G

Guest

For simplicity, I've slimmed the scope of my problem down to three fields...

1. I have a form that is bound to a table with a couple fields - PersonID,
FirstName, LastName.

2. I don't have a control on the form that is bound to PersonID, but I can
reference the value of PersonID in VBA by using the following syntax ...
Me!PersonID

3. I passed this form to subroutine in a module.

4. In the module, I've lost the "Me" object, so the syntax from #2 above
doesn't work.

How do I reference the value of PersonID in the subroutine?


' how I would like to do it, but Me![...] syntax doesn't work
Public Sub ModifyControls(MyForm as Form)

For each control in MyForm.Controls
if me![PersonID] = xyz then control.visible = false
Next

End Sub


I hope I explained this ok.
Thanks in advance,
David
 
G

Guest

I really should post sooner - as soon as I post I figure it out!!!

I used the word "recordset" in this post, and that sparked my brain. Within
the subroutine I set a recordset as follows....

Set rs = MyForm.Form.Recordset

and can reference by ...

rs.Fields("" & strFieldName & "").Value


Thanks all
David
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top