form name in openargs

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
 
J

JEM

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?
 
S

Sylvain Lafontaine

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.
 

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