How do you passing a form name to a general procedure

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have quite a few forms and in each form, there is an event procedure
calling the same general procedure. For example:

---------------- In a form Event----------------

On FormControl_Click ()
..
..
Call MyGenprocedure ( "MyFormName") 'the name of the form
..
..
--------In the gereral procedure section-------------

Public Sub MyGenProcedure (FormName as String)
..
..
Forms!MyFormName!Textbox1 = "ABC" (Assign the textbox value to "ABC")
..
..
 
Forms!MyFormName!Textbox1 = "ABC" (Assign the textbox value to

Public Sub MyGenProcedure (FormName as String)
Forms(FormName)!Textbox1 = "ABC"
During the execution, Access just ignored it

[ctrl][g], Tools, Options, General, "Break In Class Module"

(david)
 
Se in-line.

--
HTH
Van T. Dinh
MVP (Access)


Jim in Northwest said:
I have quite a few forms and in each form, there is an event procedure
calling the same general procedure. For example:

---------------- In a form Event----------------

On FormControl_Click ()
.
.
Call MyGenprocedure ( "MyFormName") 'the name of the form
.
Try:

Call MyGenprocedure(Me.Name)


.
--------In the gereral procedure section-------------

Public Sub MyGenProcedure (FormName as String)
.
.
Forms!MyFormName!Textbox1 = "ABC" (Assign the textbox value to "ABC")
.
Try:

Forms(FormName).Controls("Textbox1") = "ABC"

Note: in your code, the argument of the Sub is "FormName" but then you
didn't use it in the code. In the procedure code, you used "MyFormName"
(explicit name of the Form?)
 

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

Back
Top