form name in openargs

  • Thread starter Thread starter JEM
  • Start date Start date
J

JEM

I am trying to do something that seems like it should be simple, but i
can't get it right. I have a popup form for users to enter or edit
organizations (frmOrganizations) that can be opened from various forms
in the database by double clicking on a control (cboOrganization). I
want to be able to send the name of the form in the openargs when they
double click so that when they finish entering or editing the
organization, the control (cboOrganization) can be populated with the
value they entered or requeried. I thought i could do it this way
rather than having to look for the originating form using
currentproject.allforms. Any ideas?

Thanks,
Jenn
 
DoCmd.OpenForm "frmOrganizations", OpenArgs:=Me.Name

-Tom.
Microsoft Access MVP





- Show quoted text -

Thanks, i got that part, the part that i can't figure out how to do is
to requery the control on the form based on what the value of the
openargs is. You can't do Forms!me.openargs!cboOrganization.Requery.
I also tried:

Dim frm As Form
Set frmname = me.openargs
forms!frmname!cboOrganization.requery

Doesn't work either. Any ideas?
 
DoCmd.OpenForm "frmOrganizations", OpenArgs:=Me.Name

-Tom.
Microsoft Access MVP




- Show quoted text -
Thanks, i got that part, the part that i can't figure out how to do is
to requery the control on the form based on what the value of the
openargs is. You can't do Forms!me.openargs!cboOrganization.Requery.
I also tried:

Dim frm As Form
Set frmname = me.openargs
forms!frmname!cboOrganization.requery

Doesn't work either. Any ideas?

Me.OpenArgs is a string, not a form; so as Tom has said, you must write
something like:

Dim frm As Form
Set frmname = Forms (me.openargs)
frm!cboOrganization.requery

You could also add a public variable to your frmOrganizations form and
populates it with the current form (untested):

' On the frmOrganizations form:
Public frm As Form

' When opening the frmOrganizations form from another form:
DoCmd.OpenForm "frmOrganizations", acNormal
Set Forms("frmOrganizations").frm = Me
...

When you are finished with it, you can reset the value of frm to Null in
order to catch any glitch.
 
Back
Top