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?)
 
Back
Top