How do you passing a form name to a general procedure

  • Thread starter Jim in Northwest
  • Start date
J

Jim in Northwest

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")
..
..
 
D

david epsom dot com dot au

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)
 
V

Van T. Dinh

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