By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,486 Members | 2,067 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,486 IT Pros & Developers. It's quick & easy.

Making a Macro or Module

P: n/a
I have code I'm using repeatedly in my program, and would like to convert it to
a module or macro, can anyone assist me? Thank you in adavance for all
assistance, it is greatly appreciated.

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "ffldName or Formname"
DoCmd.Close
DoCmd.OpenForm stDocName, , , stLinkCriteria
Forms!frmKennel1!FormHolder = "Name of Form Currently On"

I would like to be able to create code to get the current open form name and
the form name to open on double click based on the field name being the same as
the form name and save it on a hidden form that is open all the time. Thank you
again.

Nov 13 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
If that form is open all the time, then create a public sub of that form to
set the name, then call it from your form:

In AlwaysOpenForm:

Public Sub SetVisibleForm(fromName As String)
Me.txtVisibleForm = formName
End Sub
In the code for 'Open' buttons for your other forms:
DoCmd.Close acForm, Me.Name
AlwaysOpenForm.SetVisibleForm "NewForm"
DoCmd.OpenForm "NewForm"
Darryl Kerkeslager

"Lumpierbritches" <lu*************@aol.com> wrote:
I would like to be able to create code to get the current open form name and the form name to open on double click based on the field name being the same as the form name and save it on a hidden form that is open all the time. Thank you again.


Nov 13 '05 #2

P: n/a
Now I'm confused. "I have a field that currently holds the form that's
open" - I assume this field is the data for a textbox in a hidden form, or
at least a form that is always open - which I referred to as
"AlwaysOpenForm"

"I'm trying to create a module that will keep me from having to type that
code repeatedly." I'm not sure I understand what you mean now by 'that
code'. I thought you meant code that would close and open the form, while
keeping track of the current form.

"then I would also like to SetFocus on the field that was originally double
clicked from on that original form." - this is really throwing me. Usually
you click on a button to open a form, but hey, I see that you want to click
on the name of a form, stored in a textbox. But maybe not, since you then
want to move the focus back to the same field ...?

"When the form is open in edit mode, in code I would like to be able to get
the name of the form, so that I don't have to change the module on each
form?"

Perhaps if you used 'Form A', 'Form B', this would be more clear. Perhaps I
just don't get the real purpose here. What module are you talking about
changing? Please, if you explain it slowly for me, I know I can understand,
but at this point, I'm lost as to what it is you really want to accomplish.
Darryl Kerkeslager
(via EMail)
Darrel,

Thank you for your post, but I'm not sure I understand what you're saying. I have a field that currently holds the form that's open. I'm trying to
create a >module that will keep me from having to type that code repeatedly.
Dim frm as form
frm = fldFormsHolder

DoCmd.OpenForm frm

then I would also like to SetFocus on the field that was originally double clicked from on that original form.
When the form is open in edit mode, in code I would like to be able to get the name of the form, so that I don't have to change the module on each
form?
Michael "Darryl Kerkeslager" <Ke*********@comcast.net> wrote: If that form is open all the time, then create a public sub of that form to set the name, then call it from your form:

In AlwaysOpenForm:

Public Sub SetVisibleForm(fromName As String)
Me.txtVisibleForm = formName
End Sub
In the code for 'Open' buttons for your other forms:
DoCmd.Close acForm, Me.Name
AlwaysOpenForm.SetVisibleForm "NewForm"
DoCmd.OpenForm "NewForm"
Darryl Kerkeslager

Nov 13 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.