2

I'm trying to access a form's recordset clone from a called function which we're using to essentially dump the data in the recordset into a table we're creating. I'm trying to call the form from the Forms collection, but I can't figure out how to insert the form name (held in a string passed to the function) into the middle of the set statement. Here's what it looks like basically:

Public Function EditFormData(frmName As String)
  Dim strSQL As String
  Dim strTableName As String
  Dim rst As DAO.Recordset
  Dim i As Integer

  Set rst = Forms![[[frmName]]].RecordsetClone

I'm at a bit of a loss here. For this particular function, I could pass a recordset to the function, but I have similar quandaries in another place, where passing one isn't an option. Thoughts?

1 Answer 1

3

Try this:

Set rst = Forms(frmName).RecordsetClone
Sign up to request clarification or add additional context in comments.

3 Comments

+1 I generally use form name, but you can also pass the form itself EditFormData(frm As Form)
Good point. The set statement would then be: Set rst = frm.RecordsetClone
That's right. Both work, and I feel like an idiot. Much appreciated, will mark as answer when it lets me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.